
Basic Utility Classes • 621
OUTPUT:
Free Memory = 4996984 Bytes
Occupied Memory = 180360 Bytes
Total Memory = 5177344 Bytes
Maximum Memory = 66650112 Bytes
After allocating 65536 bytes of memory
Free Memory = 4734824 Bytes
Occupied Memory = 442520 Bytes
After calling method gc
Free Memory = 4806352 Bytes
Occupied Memory = 370992 Bytes
Explanation: The method freeMemory() returns the amount of free memory in the Java virtual machine.
Calling the gc method may result in increasing the value returned by freeMemory. In this program, the free
memory, total memory and the occupied memory are fi rst shown. An ...