Menu

[Errno 12] Cannot allocate memory

Help
Colin
2011-10-12
2016-05-27
  • Colin

    Colin - 2011-10-12

    Hi,

    continued from .stl develops holes

    I used Meshlab to reduce my surfaces, initially to 2000. This gave good results on some models but still had holes for larger models. Increased surfaces to 6000 and ran out of memory.
    System - 8GB ram, 13GB swap, AMD Phenon II X6 3200.
    Gradually increased memory use until it aborted after ~ 30 minutes. The visualisation had to be forcibly killed. The swap didn't free up, had to reboot. 

    18:55 INFO Psyco is not available (performance will probably suffer slightly)
    18:55 INFO Enabled 6 parallel local processes
    18:55 WARNING Failed to locate the fonts directory 'fonts' below ''. Falling back to '/usr/share/librecad/fonts, /usr/share/qcad/fonts'.
    18:55 INFO Font directory: /usr/share/qcad/fonts
    18:55 INFO Loading task settings file: /home/colin/hullform/output/rail3d.conf
    18:55 INFO Imported STL model: 839 vertices, 0 edges, 1444 triangles
    18:56 INFO Loading task settings file: /home/colin/hullform/output/rail3d.conf
    18:56 INFO Imported STL model: 4225 vertices, 0 edges, 6000 triangles
    20:04 ERROR An unexpected exception occoured: please send the text below to the developers of PyCAM. Thanks a lot! Traceback (most recent call last):   File "/usr/lib/pymodules/python2.7/pycam/Gui/Project.py", line 4041, in generate_toolpath     self.model, toolpath_settings, callback=draw_callback)   File "/usr/lib/pymodules/python2.7/pycam/Toolpath/Generator.py", line 62, in generate_toolpath_from_settings     backend, callback)   File "/usr/lib/pymodules/python2.7/pycam/Toolpath/Generator.py", line 356, in generate_toolpath     toolpath = generator.GenerateToolPath(motion_grid, callback)   File "/usr/lib/pymodules/python2.7/pycam/PathGenerators/PushCutter.py", line 89, in GenerateToolPath     progress_counter)   File "/usr/lib/pymodules/python2.7/pycam/PathGenerators/PushCutter.py", line 144, in GenerateToolPathSlice     callback=progress_counter.update):   File "/usr/lib/pymodules/python2.7/pycam/Utils/threading.py", line 641, in run_in_parallel_local     pool = __multiprocessing.Pool(__num_of_processes)   File "/usr/lib/python2.7/multiprocessing/__init__.py", line 229, in Pool     return Pool(processes, initializer, initargs, maxtasksperchild)   File "/usr/lib/python2.7/multiprocessing/pool.py", line 134, in __init__     self._repopulate_pool()   File "/usr/lib/python2.7/multiprocessing/pool.py", line 197, in _repopulate_pool     w.start()   File "/usr/lib/python2.7/multiprocessing/process.py", line 130, in start     self._popen = Popen(self)   File "/usr/lib/python2.7/multiprocessing/forking.py", line 120, in __init__     self.pid = os.fork() OSError:  Cannot allocate memory

    free memory 315MB  3% (less when system locked up)

    total memory 8070 MiB

    free swap 0MB  0%

    total swap 13289 MiB

     
  • Lars

    Lars - 2011-11-17

    Hi bigtreeman,

    this seems to be a problem with Python 2.7. Please read the FAQ: http://sourceforge.net/apps/mediawiki/pycam/index.php?title=FAQ#PyCAM_consumes_all_my_memory.21

    Sadly the root cause of this bug is still unknown. Thus if you discover anything: please tell us!

    cheers,
    Lars

     
  • Jason

    Jason - 2011-12-14

    The follow patch fixes the memory leak, or at least seems to for me. It  appears that in Python 2.7 pool objects don't clean themselves up correctly when garbage collected.

    diff -r -u pycam-0.5.1.orig/src/pycam/Utils/threading.py pycam-0.5.1/src/pycam/Utils/threading.py
    -- pycam-0.5.1.orig/src/pycam/Utils/threading.py 2011-06-10 10:54:51.000000000 -0400
    +++ pycam-0.5.1/src/pycam/Utils/threading.py 2011-11-13 15:50:34.294437639 -0500
    @@ -639,18 +639,21 @@
         if __multiprocessing and not disable_multiprocessing:
             # use the number of CPUs as the default number of worker threads
             pool = __multiprocessing.Pool(__num_of_processes)
    -        if unordered:
    -            imap_func = pool.imap_unordered
    -        else:
    -            imap_func = pool.imap
    -        # Beware: we may not return "pool.imap" or "pool.imap_unordered"
    -        # directly. It would somehow loose the focus and just hang infinitely.
    -        # Thus we wrap our own generator around it.
    -        for result in imap_func(func, args):
    -            if callback and callback():
    -                # cancel requested
    -                break
    -            yield result
    +        try:
    +            if unordered:
    +                imap_func = pool.imap_unordered
    +            else:
    +                imap_func = pool.imap
    +            # Beware: we may not return "pool.imap" or "pool.imap_unordered"
    +            # directly. It would somehow loose the focus and just hang infinitely.
    +            # Thus we wrap our own generator around it.
    +            for result in imap_func(func, args):
    +                if callback and callback():
    +                    # cancel requested
    +                    break
    +                yield result
    +        finally:
    +            pool.terminate()
         else:
             for arg in args:
                 if callback and callback():

     
  • Lars

    Lars - 2012-01-03

    Hi jferrara,

    that's fantastic news - thanks for taking the time to investigate this issue!
    I applied a slightly adapted patch (just reducing the "try" branch down to the "for" loop) to the code and tested it with Python 2.5, 2.6 and 2.7. The issue seems to be fixed completely. This solves a big problem for all users of recent distribution releases. Thanks a lot!

    cheers,
    Lars

    PS: committed as r1223

     
  • Nobody/Anonymous

    Hi jferrara:
        I upgrade my ubuntu from 11.10 to 12.04. Only python 2.7 can be used in this system. So I followed your instruction to fix this problem. It worked.

    thanks,
    Brian

     
  • niebrian

    niebrian - 2012-05-02

    Hi all,

      I upgrade ubuntu from 11.10 to 12.04, both of freeCAD and pycam are not worked. thanks for the help of web, I fixed it. I recorded the procedure here: http://briananddou.blogspot.com/2012/05/compile-freecad-in-ubuntu-1204.html 
      Hope I can help others,

    Brian

     

Log in to post a comment.