Fragmentation Problems

A frequent problem for J2ME applications that are running on a KVM implementation without compacting garbage collection is a memory paradox: Runtime.freeMemory() reports lots of free memory, but a memory allocation following immediately fails and causes an OutOfMemoryException.

This issue was especially problematic with early versions of the SUN KVM. The SUN KVM now provides a compacting garbage collector, so this problem seems less important. However, some KVM implementations may not provide a compacting garbage collector for some reason, so you should at least know about the characteristics of the problem.

The reason for the discrepancy between the return value of Runtime.freeMemory() and the ability to allocate a certain ...

Get Java™ 2 Micro Edition Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.