Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; '64-bit': 0.07; 'memory.': 0.07; '32-bit': 0.09; 'fixed,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'windows,': 0.09; 'python': 0.11; 'bug': 0.12; 'circumvent': 0.16; 'limiting': 0.16; 'nice:': 0.16; 'presume': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sadly': 0.16; 'stupid,': 0.16; 'unresponsive': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'aspect': 0.24; 'script': 0.25; 'equivalent': 0.26; 'order.': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'you?': 0.31; 'claiming': 0.31; 'know.': 0.32; 'weeks': 0.32; 'running': 0.33; 'guess': 0.33; 'used,': 0.33; 'could': 0.34; 'problem': 0.35; 'knowledge': 0.35; 'received:84': 0.35; 'there': 0.35; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'results.': 0.60; 'ago,': 0.61; 'back': 0.62; 'become': 0.64; 'more': 0.64; 'life': 0.66; 'caused': 0.69; 'limit': 0.70; 'isaac': 0.84; 'usage.': 0.84; 'edwards': 0.91; 'killed': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Roel Schroeven Subject: Re: l = range(int(1E9)) Date: Thu, 30 Apr 2015 21:40:32 +0200 References: <87k2wtvbx1.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: d54c57c9e.access.telenet.be User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430422852 news.xs4all.nl 2904 [2001:888:2000:d::a6]:44543 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89665 Grant Edwards schreef op 2015-04-30 18:33: > On 2015-04-30, 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? > > I presume "don't do that" has already occured to you? A few weeks ago, I had a bug in a Python script which caused it to consume all memory, thrashed my computer; the system become unresponsive and it was very difficult to kill the process and get everything back in working order. Then I thought (foolishly) that the bug was fixed, so I ran the script again, with the same disastrous results. And then again. Stupid, I know. A way to limit memory usage would have been nice: the script would have been killed before it could grind the whole system to a halt. > You can always use ulimit to limit the memory allowed for the process > running Python. Sadly in my case the OS is Windows, and as far as I know it doesn't have a ulimit equivalent for limiting memory usage. I guess I could have used 32-bit Python instead of 64-bit Python to limit available memory. -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven