how to set max heap size for Python

这一生的挚爱 提交于 2019-12-25 02:38:29

问题


I'd like to set max heap size for my python code. In my server environment, a process in running long time with huge heap size is killed automatically. I already know if heap size is above 40G, the process will be killed. And if around 20G~30G, it's OK. Thus, I need to keep max heap size within 20G.

To realize that, I found similar question in stackoverflow(How to limit the heap size?), and tried it.

here is header of my code.

import resource
rsrc = resource.RLIMIT_DATA
resource.setrlimit(rsrc, (7340032, 20971520))

But my code exceeds that limit if I check process status with top command. It takes around 45G memory.

What's wrong with my way to set limit?

My python code executes PCA analysis with scikit-learn library. I confirmed numpy array size is around 6G with nbytes attribute.

thanks!

来源:https://stackoverflow.com/questions/25589911/how-to-set-max-heap-size-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!