Because of heap size limitation, my Midlet needs to act in different way for different heap size. for instance, it should load more or less bitmap fonts.
Asked
Active
Viewed 2,533 times
1 Answers
1
// Get current size of heap in bytes
long heapSize = 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();
Also refer this Runtime Java Documentation.

bharath
- 14,283
- 16
- 57
- 95
-
maxMemory method is missing in CLDC 1.1 but a valid answer anyways. – Trax Apr 14 '15 at 11:24