[Python-Dev] MemoryError... how much memory? (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Thu Oct 28 01:27:15 CEST 2010


On Thu, Oct 28, 2010 at 8:00 AM, Ben Finney <ben+python at benfinney.id.au> wrote:

Facundo Batista <facundobatista at gmail.com> writes:

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. It also depends on how much is being requested. The caller knows that amount, surely?

For a server process, the MemoryError in the log won't always have the context information showing what the values were in the calling frames. The idea behind Facundo's request is similar to the reason why we print the type names in a lot of TypeErrors.

If you see MemoryError (5 bytes), the things you go looking for are very different from those you look for when you see MemoryError(1 gajillion bytes). (i.e. for the former, you look for a memory or other resource leak, for the latter, you look for the reason your code is trying to get 1 gajillion bytes from the OS). If a long-lived server isn't crashing but is still getting MemoryError occasionally, problems with specific oversized requests are much more likely than a general resource leak (as those usually bring the whole process down eventually).

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list