简体   繁体   中英

Set python memory limit on Ubuntu 12.04

Currently my script runs an algorithm that require allocation of many objects, as a result I receive a "Memory Error".

However, from monitoring my memory usage, the error occurs when I'm only using 4Gb out of 16Gb of my total memory capabilities on my computer. Is there a way to increase the allowed memory consumption for my python script up to 16Gb?

I have tried to use https://docs.python.org/2/library/resource.html#resource.setrlimit and set everything to MAX_VALUE, yet I still have the error at 4Gb of memory consumption.

Any pointers will be helpful.

I have read: Set Python memory limit and many posts like it but they don't directly address my problem.

Here is a what "ulimit -a" outputs, if it is of any use.

evan@evan-box:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 96626
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 96626
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

thanks.

Are you running a 64bit kernel check the following

file /sbin/init

uname -m

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM