[pypy-issue] [issue1608] Memory leak when accessing a dictionary with an non-existent key

Armin Rigo tracker at bugs.pypy.org
Sat Sep 21 10:44:25 CEST 2013

Armin Rigo <armin.rigo at gmail.com> added the comment:

pypy_bug_ukey.py shows an example where it is expected to get MemoryError: you
are building a so-called "unicode strategy" dictionary, which means a dict that
is specialized to store unicode objects only as keys.  But then when you try to
look up an object of a different type --- like string --- it will fall back the
whole dictionary to a general-typed dictionary.  In this case we run out of
memory trying to make the general-typed copy.

This is done because the alternative is harder to implement: that would be
trying to search the internal unicode-only dictionary for a plain string object.
 The drawback is mainly that it is surprizing to get a MemoryError on a plain
lookup, but otherwise the drawback is generally relatively minor, except in
special cases like yours.

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list