[Python-3000] MemoryError oddities

Amaury Forgeot d'Arc amauryfa at gmail.com
Fri Aug 1 01:04:50 CEST 2008


2008/7/21 Georg Brandl <g.brandl at gmx.net>:
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41297 refs]
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41317 refs]
>>>> b"a"*sys.maxsize
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
>  File "<stdin>", line 1, in <module>
> MemoryError
> [41337 refs]
>
> This probably has to do with the fact that this MemoryError is a prebuilt
> instance.

I corrected this with r65341.
But this prebuilt MemoryError has another nasty consequence:
when PyErr_NoMemory is raised, the traceback is attached to the
prebuilt object,
and all local variables of the failing procedure are still referenced
and will not be freed.

This seems to defeat the purpose of the prebuilt MemoryError...

-- 
Amaury Forgeot d'Arc


More information about the Python-3000 mailing list