L'espace mémoire en octet,méga,
Résolu/Fermé
A voir également:
- L'espace mémoire en octet,méga,
- Espace insécable word - Guide
- Libérer espace gmail - Guide
- Mémoire vive - Guide
- Espace stockage google - Guide
- Espace en html - Astuces et Solutions
1 réponse
KX
Messages postés
16754
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
25 novembre 2024
3 020
16 déc. 2010 à 14:55
16 déc. 2010 à 14:55
C'est marqué dans la documentation : measured in bytes.
Mais tu peux te prendre une méthode d'affichage qui choisiras les bonnes unités :
Mais tu peux te prendre une méthode d'affichage qui choisiras les bonnes unités :
import java.text.DecimalFormat; public static String memoire(long capacite) { String IEC_60027_2=" KMGPEZY"; int i; double maxCapacite; for( i=0, maxCapacite=1; i<IEC_60027_2.length() && capacite>=1024*maxCapacite; i++, maxCapacite*=1024 ); return new DecimalFormat("0.00 "+IEC_60027_2.charAt(i)+"io") .format((double) capacite/maxCapacite); } public static String statsRuntime() { Runtime r=Runtime.getRuntime(); long a=r.totalMemory(), b=(a-r.freeMemory()), c=r.maxMemory(); return "Mémoire de la JVM : "+memoire(b)+" utilisés sur "+memoire(a)+ " disponibles (extensible jusqu'à "+memoire(c)+")"; } public static void main(String args[]) { System.out.println(statsRuntime()); }
16 déc. 2010 à 15:31