title: Python multiprocess.pool will fork large memory from parent process
body: <p>I am using <code>multiprocess.pool</code>, and I am also using the parameter <code>maxtasksperchild</code>.</p>
  
  <p>Now the problem is, when the <code>maxtasksperchild</code> has reached, the process pool will kill the origin child process, and create a new one. But the child process seems to be created by <code>fork()</code>, which will duplicate large memory from parent process.</p>
  
  <p>For me, I want parent memory to be a lot ,but I do not want the child process to have much memory(it will even not use the memory), and I also want to use the ability of <code>multiprocess.pool</code>.</p>
  
  <p>Could anyone help?</p>
  
  <p>Demo code(this will cost 3.6G memory):</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import multiprocessing
  import time
  from setproctitle import setproctitle
  
  cache_list = []
  
  
  def init_child_process():
      # set the name of the child process
      setproctitle('child process')
  
  
  def child_task():
      time.sleep(1)
  
  
  def test():
      # make large memory for parent process
      # attention, each process will cost 600M, total is 3.6G
      for i in xrange(500000):
          import random
          size = random.randint(10, 20)
          data = {
              u"key_1": u"value_1",
              u"key_2": u"value_2",
              u"key_3": u"value_3",
              u"key_4": u"long_value " * size,
              u"key_5": u"long_value " * size
          }
          doc_list = [data] * 10
          cache_list.append(doc_list)
  
      # create child process pool
      pool = multiprocessing.Pool(5, initializer=init_child_process,
                                  initargs=())
  
      # add tasks, make the pool to spawn the child processes
      for i in xrange(10):
          pool.apply_async(child_task)
  
      # if you add a breakpoint here(or use pdb)
      # you will find both parent process and child processed have large memory
      # maybe it is due to fork()
      # but I want the child process not fork from parent
      import pdb
      pdb.set_trace()
  
  
  if __name__ == '__main__':
      test()
  </code></pre>