[Tutor] Question about the memory manager

Peter Otten __peter__ at web.de
Mon Jan 11 10:40:14 EST 2016


Oscar Benjamin wrote:

> On 11 January 2016 at 12:15, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>
>> But I think that it definitely is heavily OS dependent.
>> It should work in most *nix environments the first time
>> you call the function. But on second call I'd expect
>> all bets to be off. And in most real-time OS's memory
>> goes right back to the OS pool - but even there it
>> would probably be available I guess, at least the first
>> time.
>>
>> Maybe the theory is that if you get a memory error the
>> only sensible thing is just to log it and exit. In which
>> case you only ever call this once.
>>
>> Steven, Did you try any experiments? I'm struggling
>> to come up with a reliable test scenario.
> 
> I can't even work out how you trigger a MemoryError on Linux (apart
> from just raising one). I've tried a few ways to make the system run
> out of memory and it just borks the system rather than raise any error
> - I can only interrupt it with REISUB.
> 
> Here's a simple one:
> 
> $ python -c 'x = []; x.append(iter(x))'
> 
> (Make sure you save all your work before trying that!)

You can set the interpreter on a diet:

$ ulimit -v 22000
$ python -c 'print "x"'
x
$ python -c 'print "x"*10**6'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
MemoryError




More information about the Tutor mailing list