This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: int left-shift causes memory leak
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: edemaine, rhettinger
Priority: high Keywords:

Created on 2004-06-26 20:36 by edemaine, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg21331 - (view) Author: Erik Demaine (edemaine) Date: 2004-06-26 20:36
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.
msg21332 - (view) Author: Erik Demaine (edemaine) Date: 2004-06-26 20:38
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.
msg21333 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-06-27 00:01
Logged In: YES 
user_id=80475

Fixed.  See Objects/intobject.c 2.111.

Thanks for the bug report.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40466
2004-06-26 20:36:39edemainecreate