Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!feeds.phibee-telecom.net!news.panservice.it!feed.xsnews.nl!border02.ams.xsnews.nl!feeder04.ams.xsnews.nl!feeder01.ams.xsnews.nl!abp001.ams.xsnews.nl!frontend-F10-20.ams.news.kpn.nl From: Cecil Westerhof Newsgroups: comp.lang.python Subject: Re: l = range(int(1E9)) Organization: Decebal Computing References: <87k2wtvbx1.fsf@Equus.decebal.nl> X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ Date: Thu, 30 Apr 2015 22:18:08 +0200 Message-ID: <87zj5ps73z.fsf@Equus.decebal.nl> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:0t0K0mAczggiPlfbLOi4YOQqqZ4= MIME-Version: 1.0 Content-Type: text/plain Lines: 64 NNTP-Posting-Host: 81.207.62.244 X-Trace: 1430425731 news.kpn.nl 21168 81.207.62.244@kpn/81.207.62.244:40681 Xref: csiph.com comp.lang.python:89669 Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel: > On 04/30/2015 02:48 PM, alister wrote: >> On Thu, 30 Apr 2015 20:23:31 +0200, Gisle Vanem wrote: >> >>> Cecil Westerhof wrote: >>> >>>> If I execute: >>>> l = range(int(1E9) >>>> >>>> The python process gobbles up all the memory and is killed. The >>>> problem is that after this my swap is completely used, because >>>> other processes have swapped to it. This make those programs more >>>> slowly. Is there a way to circumvent Python claiming all the >>>> memory? >>>> >>>> By the way: this is CPython 2.7.8. >>> >>> On what OS? If I try something similar on Win-8.1 and CPython >>> 2.7.5 (32-bit): >>> >>> python -c "for i in range(int(1E9)): pass" >>> Traceback (most recent call last): >>> File "", line 1, in >>> MemoryError >>> >>> >>> --gv >> >> also MemoryError on Fedora 21 32 bit >> > > That's presumably because you end up running out of address space > before you run out of swap space. On a 64 bit system the reverse > will be true, unless you have a really *really* large swap file > > ulimit is your friend if you've got a program that wants to gobble > up all of swap space. Yes, my system is openSUSE 64 bit. I really should look into ulimit. The default is: core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 63768 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) 63768 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited That should be fine-tuned. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof