Op Thursday 30 Apr 2015 18:55 CEST schreef Jon Ribbens: > On 2015-04-30, Cecil Westerhof <ce...@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? >> >> By the way: this is CPython 2.7.8. > > It's your operating system's job to handle processes. > > If you use xrange() instead of range() then you will get an iterator > which will return each of the numbers in turn without any need to > create an enormous list of all of them.
I did it on purpose. Wanted to now the limits. Just need to use ulimit to get a MemoryError. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list