wackywendell / tess

Python bindings to the voro++ library.
Other
36 stars 10 forks source link

MemoryError: bad allocation #4

Closed HaoliangWang closed 6 years ago

HaoliangWang commented 6 years ago

I came across this problem that when the number of input points exceeds 50,000, the meory error would jump out. However, my computer memory(RAM) is only used 20% Why is it the case? Thanks.

The error info reads as follows.

cntr = Container(pts, limits, periodic = False) Traceback (most recent call last): File "", line 1, in File "C:\Users***\Python\Python36\lib\site-packages\tess__init.py", line 162, in init len(points)) File "tess/_voro.pyx", line 210, in tess._voro.Container.cinit__ (tess/_voro.cpp:3327) MemoryError: bad allocation

wackywendell commented 6 years ago

Hi @steveshockley!

I would imagine that its trying to allocate more than the remaining 80% of your RAM, just all at once, and that fails without allocating anything. Have you tried with fewer points? If you use 1/2 or 1/10 as many, does it succeed, and use a significant fraction of your RAM?

kip-hart commented 6 years ago

Hi @wackywendell, I'm also experiencing the same error with a large number of input points.

In my case, the error occurs for anything >9000 points. Running with 4200 points, my memory usage increases from 5 to 6 GB, out of 16 total. The exact text of the error message is included below. Let me know if there's anything I can provide that might help.

Traceback (most recent call last):
  ...
    voro = tess.Container(cens, lims, periodic=False, radii=radii)
  File "C:\Users\Kenneth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tess-0.2.2-py3.6-win32.egg\tess\__init__.py", line 147, in __init__
    len(points))
  File "tess/_voro.pyx", line 259, in tess._voro.ContainerPoly.__cinit__ (tess/_voro.cpp:4060)
MemoryError: bad allocation
wackywendell commented 6 years ago

On my laptop (8 GB memory), I can create an instance with 64000 particles, see this commit for an example of the code I'm running. It does consume a very large amount of memory, but it seems to work.

Judging from this thread, I'm wondering if we're hitting the 32-bit limit; are you running a 32-bit python? It looks like you can determine that with one of these tests.

Could you tell me if you're running 32-bit Python?

kip-hart commented 6 years ago

That's a good idea! I'm currently running 32-bit Python (full version string below). I'm going to install 64-bit Python and re-run my case. If it doesn't work, I'll verify that your example works on my computer. I'll let you know the results either way - thanks!

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
kip-hart commented 6 years ago

Switching from 32-bit to 64-bit solved this problem for me. Thanks for your help! I hope it works for you too @steveshockley.

wackywendell commented 6 years ago

Great! I'm going to close this for now; let me know if that didn't work for you @steveshockley !