Randall R Schulz wrote
> When memory is exhausted in the inner loop of the program (the only
> place it's going to happen), I catch the OutOfMemoryError, release the
> storage, trigger a GC (forcing it would seem desirable, but I'm not
> sure how to do that) and report the failure back up the call chain.
> The vast majority of the RAM is used in the search tree, which is
> linked only upwardly from the leaves and the leaves are all in a
> priority queue, so relinquishing the priority queue is enough to make
> all the objects in the tree unreferenceable.
If your priority queue was only accessible via a SoftReference, then when a request from anywhere for more memory can not be fulfilled, your queue would be released automatically, avoiding an OOME.
The tricky parts are efficiently ensuring it is only softly referenced, and dealing correctly with the queue disappearing.
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachments is confidential and may be subject to legal privilege. If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.
This email has been scanned by the DMZGlobal Business Quality
Electronic Messaging Suite.
Please see http://www.dmzglobal.com/dmzmessaging.htm for details.