Namespaces
Variants
Actions
Revision as of 05:29, 7 August 2012 by hamishwillee (Talk | contribs)

How to find out the total memory in Java ME

Jump to: navigation, search

The current total heap memory of VM is retrieved using the following code

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

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.

In S60 3rd Edition devices there is a system property
com.nokia.memoryramfree

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.

SignpostIcon Graph1 52.png
Article Metadata

Code Example
Tested with
Devices(s): C3-01, Asha 305, E7-00

Compatibility
Platform(s): S40, Symbian Belle
Device(s): All

Article
Created: jaakl (15 Sep 2009)
Updated: skalogir (04 Nov 2011)
Reviewed: skalogir (20 May 2011)
Last edited: hamishwillee (07 Aug 2012)
129 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved