Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 05:56, 29 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to get the free RAM in Java ME

From Wiki
Jump to: navigation, search
See Also

Article Metadata
Created: wang_shui (29 Mar 2007)
Last edited: hamishwillee (29 Jul 2013)

The free memory is retrieved using the following code

Runtime runt=Runtime.getRuntime();
long freeMemory = runt.freeMemory();

This method however doesn't return all available possible memory in all Java VM implementations like in S60. S60 uses a VM in allocates it's VM heap memory dynamically from operating system. During startup certain amount of heap is reserved but when the memory will be used and the free amount is becoming smaller VM dynamically allocates more heap from OS. The VM also releases unnecessary heap back to operating system. This kind of implementation is important in operating environment with true multitasking capabilities like S60.

From S60 3rd Edition there is a system property

that can be used to query the available RAM available in the operating system. This is much more reliable estimate of available RAM. Although it should be understood that any other application may use this RAM.

This page was last modified on 29 July 2013, at 05:56.
53 page views in the last 30 days.