// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory()
Runtime.getRuntime().totalMemory()
;
// Get maximum size of heap in bytes. The heap cannot grow beyond this size.
// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();
// Get amount of free memory within the heap in bytes. This size will increase
// after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();
A java blog with a collection of examples and tutorials on Java and related technologies. (Under maintenance with continuous updates) Be in touch with java jazzle or k2java.blogspot.com.
Monday, April 18, 2011
Getting heap memory size in Java program
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment