Returns a string something like "64K of 256MB (25%)" that shows how much of the available memory is in use. This is the string displayed when the user clicks in the status bar.
()
| 1004 | * status bar. |
| 1005 | */ |
| 1006 | public static String freeMemory() { |
| 1007 | long inUse = currentMemory(); |
| 1008 | String inUseStr = inUse<10000*1024?inUse/1024L+"K":inUse/1048576L+"MB"; |
| 1009 | String maxStr=""; |
| 1010 | long max = maxMemory(); |
| 1011 | if (max>0L) { |
| 1012 | double percent = inUse*100/max; |
| 1013 | maxStr = " of "+max/1048576L+"MB ("+(percent<1.0?"<1":d2s(percent,0)) + "%)"; |
| 1014 | } |
| 1015 | return inUseStr + maxStr; |
| 1016 | } |
| 1017 | |
| 1018 | /** Returns the amount of memory currently being used by ImageJ. */ |
| 1019 | public static long currentMemory() { |