title: Python - Working around memory leaks
body: <p>I have a Python program that runs a series of experiments, with no data intended to be stored from one test to another. My code contains a memory leak which I am completely unable to find (I've look at the <a href="https://stackoverflow.com/questions/1435415/python-memory-leaks/1641009">other threads</a> on memory leaks). Due to time constraints, I have had to give up on finding the leak, but if I were able to isolate each experiment, the program would probably run long enough to produce the results I need. </p>
  
  <ul>
  <li>Would running each test in a separate thread help? </li>
  <li>Are there any other methods of isolating the effects of a leak?</li>
  </ul>
  
  <p><strong>Detail on the specific situation</strong></p>
  
  <ul>
  <li>My code has two parts: an experiment runner and the actual experiment code.</li>
  <li>Although no globals are shared between the code for running all the experiments and the code used by each experiment, some classes/functions are necessarily shared.</li>
  <li>The experiment runner isn't just a simple for loop that can be easily put into a shell script. It first decides on the tests which need to be run given the configuration parameters, then runs the tests then outputs the data in a particular way.</li>
  <li>I tried manually calling the garbage collector in case the issue was simply that garbage collection wasn't being run, but this did not work</li>
  </ul>
  
  <p><strong>Update</strong></p>
  
  <p>Gnibbler's answer has actually allowed me to find out that my ClosenessCalculation objects which store <em>all</em> of the data used during each calculation are not being killed off. I then used that to manually delete some links which seems to have fixed the memory issues.</p>