public class MemoryTools extends Object
| Constructor and Description |
|---|
MemoryTools() |
| Modifier and Type | Method and Description |
|---|---|
static long |
totalAvailableMemory()
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 © 2011–2026 SCIFIO. All rights reserved.