[Python-Dev] MemoryError... how much memory?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Wed Oct 27 23:08:53 CEST 2010


On 07:09 pm, facundobatista at gmail.com wrote:
>On Wed, Oct 27, 2010 at 12:05 PM, Benjamin Peterson 
><benjamin at python.org> wrote:
>>Isn't this usually when you do something like [None]*2**300? In that
>>case, wouldn't you know how much memory you're requesting?
>
>It could happen on any malloc. It depends on how much you have free.
>
>Don't think on getting a MemoryError on a python you just opened in
>the console. Think about a server with a month of uptime, where you
>have all the memory fragmented, etc.
>>Also, why is that useful?
>
>It helps to determine why we're having some Memory Errors on our
>long-lived server, how is the behaviour when that happens, etc.

But... If you allocated all of your memory to some garbage, and then a 5 
byte string can't be allocated, you don't really care about the 5 byte 
string, you care about the garbage that's wasting your memory.

Tools like heapy will give you a lot of information.  Maybe it wouldn't 
hurt anyone to have more information in a MemoryError.  But I don't 
think it's going to help a lot either.  It's not the information that 
you're really interested in.

Jean-Paul


More information about the Python-Dev mailing list