How to clear memory?
807589Nov 29 2008 — edited Dec 1 2008Hi,
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.