I am using the Python resource module in order to limit my memory usage, in the following way:
import resource
rsrc = resource.RLIMIT_AS
soft, hard = resource.getrlimit(rsrc)
resource.setrlimit(rsrc, (soft, 5*1024*1024)) # hard limit = 5GB
However, I encountered the following problems:
- The current
hard
limit is-1
. What is the meaning of this value? The problem is that, because it is negative, I cannot set the hard limit to anything higher, and I get an error message (ValueError: current limit exceeds maximum limit
). - Contrary to the documentation, the
resource
module has noRLIMIT_VMEM
. When trying to accessresource.RLIMIT_VMEM
, I get an error (AttributeError: 'module' object has no attribute 'RLIMIT_VMEM'
). Could this be caused by some compatibility issues with my OS?