Symbian devices use dynamic memory allocation for Java, meaning that the memory heap reserved for Java grows and shrinks dynamically based on memory consumption. Because of this, the values returned by the Runtime.totalMemory and Runtime.freeMemory methods can vary over time. Symbian devices support a maximum Java heap size of 32 MB.
Not all Java objects are stored in the Java heap. Some objects can also be stored in the host OS memory. For example, only the handle for an Image is stored in the Java heap, while the actual bitmap is stored in the host OS memory. This can cause a discrepancy between the value returned by the Runtime.freeMemory method and the actual free RAM on the device. It is possible that an OutOfMemoryError is thrown even when it seems that the object should fit in the Java heap.
From S60 3rd Edition onwards, you can also use the com.nokia.memoryramfree system property to query the amount of free RAM on the device.