public class MemoryTools extends Object
|Constructor and Description|
|Modifier and Type||Method and Description|
Returns the total amount of remaining memory.
public static long totalAvailableMemory()
Slightly tricky: totalMemory() returns the amount of RAM claimed currently, not the maximum amount Java will claim when asked (that is maxMemory() instead). Likewise, freeMemory() returns the number of free bytes in the currently claimed chunk of RAM, not the number of bytes still available for Java.
Therefore, a little arithmetic is required to obtain the real number of available bytes for us to use.
Copyright © 2015–2017 SCIFIO. All rights reserved.