Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to clear memory?

807589Nov 29 2008 — edited Dec 1 2008
Hi,

I am writing a genetic algorithm in Java to help optimize a problem. To do this, I need to run a set of code hundreds of times over and over again in rapid succession (let's call this code the 'evaluator', since it essentially evaluates all the 'genes' in the genetic algorithm.

The problem is that in doing this, my genetic algorithm crashes because Java runs out of memory/heap space (java.lang.OutOfMemoryError: Java heap space). This is probably because the set of code I run generates many arrays, objects, graphs, etc, that I don't think the Java Garbage collector can get in time to.

Is there a way to clear the Java heap each time I run the evaluator? (I have access to the evaluator's code so I can modify it directly).

Pratik.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2008
Added on Nov 29 2008
25 comments
886 views