[Tutor] Question about the memory manager

Steven D'Aprano steve at pearwood.info
Sun Jan 10 11:16:21 EST 2016


On Sun, Jan 10, 2016 at 11:53:22AM +0000, Albert-Jan Roskam wrote:
> Hi,
> 
> I just found a neat trick to free up an emergency stash of memory in a 
> funtion that overrides sys.excepthook.

> rainydayfund = [[] for x in xrange(16*1024)] # or however much you need
> def handle_exception(e):
> global rainydayfund
> del rainydayfund
> ... etc, etc ...

I was going to write a scornful email about how useless this would be. I 
still think it's useless, but I see that the idea comes from Alex 
Martelli, who normally knows what he is talking about, so that makes me 
pause and think and perhaps do some experiments before commenting.

Even the best programmer can have some weird idiosyncratic 
superstitions, but only a fool would assume that Alex Martelli has got 
it wrong without doing some careful investigation. So let me get back to 
you :-)


-- 
Steve


More information about the Tutor mailing list