title: Multiprocessing manager process does not free memory
body: <p>In the app I'm developing I use a <code>multiprocessing.BaseManager</code> to do some heavy and complex computations in parallel with the main process. I use a Manager and not a Pool because these computations are implemented as a <code>class</code> and needed to be performed only once in a while.</p>
  
  <p>Each time I create a new instance of computing class in the manager, call its' methods, get back the results, then delete the instance and call gc.collect() in the manager.</p>
  
  <p>Here's a pseudo-code to demonstrate the situation:</p>
  
  <pre><code>import gc
  from multiprocessing.managers import BaseManager
  
  class MyComputer(object):
     def compute(self, args):
        #several steps of computations
        return huge_list
  
  class MyManager(BaseManager): pass
  MyManager.register('MyComputer', MyComputer)
  MyManager.register('gc_collect', gc.collect)
  
  if __name__ == '__main__':
     manager = MyManager()
     manager.start()
  
     #obtain args_list from the configuration file
  
     many_results = []
     for args in args_list:
        comp = manager.MyComputer()
        many_results.append(comp.compute(args))
        del comp
        manager.gc_collect()
  
     #do somthing with many_results
  </code></pre>
  
  <p>The result of a computation is big (200Mb-600Mb). And the problem is: according to <code>top</code>, resident memory used by manager process is growing significantly (by 50Mb to 1Gb) after a computation. It grows <em>much faster</em> if a single <code>comp</code> object is used in all computations or if <code>manager.gc_collect()</code> is not called. So I guess the object is indeed deleted and garbage collector works, yet something is still left behind.</p>
  
  <p>Here's a plot of resident memory used by the Manager process during five rounds of computations: <a href="http://i.imgur.com/BY6KuXD.png" rel="nofollow">http://i.imgur.com/BY6KuXD.png</a></p>
  
  <p>My questions are: </p>
  
  <ol>
  <li>Do I need to search for memory leaks in MyComputer implementation, or is this just a feature of python's memory management system?</li>
  <li>If the latter is true, are there any means to force a manager process to return it's "freed" memory to the OS?</li>
  </ol>