title: How to solve OutOfMemoryError?
body: <p>For a project for school I have to program different kind of algorithms. The problem is, I got a working algorithm. But I have to run it several times and after some time it gives me the following errors:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space</p>
  </blockquote>
  
  <p>I know what the error means, but is it possible to let Java search for empty space during the run? I know it uses a lot of space which isn't used at some point. It sets a lot of object to null during the application run and create a lot of new ones, because of this it runs out of memory.</p>
  
  <p>So concrete: is it possible to let the JVM free some space that is set to null? Or free some space in the time the program is running? I know I can set the JVM to more space, but sooner or later I will run to the same problem.</p>
  
  <p>If you need my IDE (in case it is IDE specific) it is Eclipse.</p>