08-06-2008 04:23 AM
I have a basic memory management question:
Say I have a BigVector holding 500 persistent objects which consumes around 2MB.
Each object is grouped.
I would like to be able to free this vector and release all the memory used, I have tried various things including removing each object from the vector, calling LowMemoryManager.markAsRecoverable on each, committing the empty vector and calling System.gc()
No matter what I try I don't seem to recover the memory until I reset the device (at least according to Options --> Status --> File Free).
What is the correct way to destroy persistent objects and recover the memory immediately?
08-06-2008 03:42 PM
I'm my app i just call PersistentStore.destroyPersistentObject().
I would assumed this will free the allocated memory.
In my case I don't want to remove the entire hashtable that I have in PersistentStore, just elements from one vector which is contained in it. So my question could be rephrased as "how do I release individual grouped persistent objects without destroying the entire store and ensure that the memory is recovered immediately?"
08-07-2008 12:49 AM
Well, it looks like the "File Free" status value is just confusing me, if I "release" 500 objects the value does not change (unless I reset the device), but if I then create another 500 objects the value still doesn't change so I assume the subsequent allocation is using the previously freed memory?
Should I be this confused or am I missing something obvious?
08-08-2008 03:11 PM
Resetting the BlackBerry results in a full garbage collection, which would reclaim the memory you are using. There is no way to guarantee that your memory is immediately freed. I recommend you have a look at the "Garbage collection in the BlackBerry Java Development Environment" and "Low memory management in the BlackBerry Java Development Environment" white papers found here: