l = range(int(1E9))

Cecil Westerhof Cecil at decebal.nl
Thu Apr 30 19:26:38 CEST 2015

Op Thursday 30 Apr 2015 18:33 CEST schreef Grant Edwards:

> On 2015-04-30, Cecil Westerhof <Cecil at decebal.nl> 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?
> I presume "don't do that" has already occured to you?

Well, it is just playing with the possibilities/limits of Python.
Better getting the problem now, then when I can not afford to lose
time. ;-)

> You can always use ulimit to limit the memory allowed for the
> process running Python.

That works, yes. Now I get a MemoryError and the other processes are
left alone. Now determining what are the best values.

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

More information about the Python-list mailing list