l = range(int(1E9))

Cecil Westerhof Cecil at decebal.nl
Fri May 1 01:19:51 EDT 2015


Op Thursday 30 Apr 2015 23:41 CEST schreef Tim Chase:

> On 2015-04-30 22:18, Cecil Westerhof wrote:
>> Op Thursday 30 Apr 2015 20:59 CEST schreef Dave Angel:
>>> 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:
> [snip]
>> max memory size         (kbytes, -m) unlimited
>
> Note that AFAIK, "ulimit -m" doesn't work on Linux
>
> http://unix.stackexchange.com/questions/129587/does-ulimit-m-not-work-on-modern-linux
>
> Based on some quick testing[1], it doesn't appear to work on OpenBSD
> or FreeBSD either.

Yes, as I already found out you need to use -v. But it would be nice
that there was an indication that -m is obsolete.

Depending on the available memory you could use something like:
    ulimit -v $((4 * 1024 * 1024))

I can then do:
    l = range(int(1E8))
but:
    l = range(int(1E9))
gives MemoryError.

And if I can also do (from another thread):
    happy_number_list(int(1E8))
if I did not something memory consuming.


And if a (Python) process should use significantly less, it could be a
good idea to tweak the ulimit call.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list