[ python-Bugs-980419 ] int left-shift causes memory leak

SourceForge.net noreply at sourceforge.net
Sat Jun 26 18:31:52 EDT 2004


Bugs item #980419, was opened at 2004-06-26 15:36
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980419&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
>Priority: 6
Submitted By: Erik Demaine (edemaine)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: int left-shift causes memory leak

Initial Comment:
The following Python one-liner causes the Python image
size to grow quickly (beyond 100 megabytes within 10
seconds or so on my Linux 2.4.18 box on an Intel
Pentium 4):

while True: 1 << 64

The point is that 1 << 64 gets automatically turned
into a long.  Somehow, even after all pointers to this
long disappear, it (or something produced along the
way) sticks around.  The same effect is obtained by the
following more natural code:

while True: x = 1 << 64

There is an easy workaround; the following code does
not cause a memory leak:

while True: 1L << 64

However, a memory leak should not be intended behavior
for the new int/long unification.

----------------------------------------------------------------------

Comment By: Erik Demaine (edemaine)
Date: 2004-06-26 15:38

Message:
Logged In: YES 
user_id=265183

Forgot to mention that this arises even on the latest CVS
version of Python 2.4, and on other versions of Python 2.4 I
had lying around.  It does not arise on Python 2.2, which is
pre-int/long unification I think.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980419&group_id=5470



More information about the Python-bugs-list mailing list