Skip to main content
GameDev.net gamedev.net
🔒 Locked

Memory fragmentation

Started by Moose6912 Dec 26, 2004 at 2:29 PM 2 replies 1.5k views
Original Post
Moose6912
Moose6912
To avoid memory fragmentation which is a real issue in programming J2ME midlets,do you all load your images,datatypes in descending order where you load the largest image or datatype first and the small images/datatype in the end?Do this make a difference at all?
Sneftel
Sneftel
It doesn't tend to make much of a difference, though I suppose that if I had to choose I'd load the large things first. The thing you really want to avoid is lots of allocation and deallocation at runtime, especially of variable-length arrays. This sort of allocator churning is what'll really fragment your heap.
Zahlman
Zahlman
It's hard to control very well anyway, and you'll also have to adjust things for different phones. On Series 40 phones with a small heap, you'll want to do your best to deallocate anything you don't need, generally speaking. Whereas on the Series 60s that seems to be about the worst possible thing - there is good evidence of a(n internal) memory leak in getResourceAsStream().
mixa
mixa
Just to mention that Siemens phones had non-compacting GC for a long time (not sure if they use compacting GC on non-symbian phones now but hope so).

Some phones may fragment heap even using compacting GC (VM may reserve non-relocatable data in heap).

As heap memory grows on phones, it is easier now to manipulate with images, but still if you use almost all of heap, it would be good to consider GC issues.

Mike

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.