Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cyclic garbage collection support to object arrays (Trac #1003) #1601

Closed
thouis opened this issue Oct 19, 2012 · 4 comments
Closed

Add cyclic garbage collection support to object arrays (Trac #1003) #1601

thouis opened this issue Oct 19, 2012 · 4 comments

Comments

@thouis
Copy link
Contributor

thouis commented Oct 19, 2012

Original ticket http://projects.scipy.org/numpy/ticket/1003 on 2009-02-08 by @stefanv, assigned to unknown.

Melt van Schoor reported a memory leak, illustrated by the following code:

from numpy import *

class Lattice:
   def __init__(self, size):
      self.size = size 

      self.lat = empty((self.size, self.size), dtype=object)
      for x in range(self.size): 
         for y in range(self.size):
            self.lat[x,y]=Location(self)

# compare with this..
#      self.lat=[[Location(self) for y in xrange(self.size)] for x in xrange(self.size)]

class Location(list):
    pass
    def __init__(self, parent):
      self.parent=parent  # This line is crucial to triggering the leak

# To trigger, run this (it will consume increasing amounts of memory)
for t in xrange(2000000): Lattice(80)
@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

@pv wrote on 2009-02-09

The problem appears to be that Numpy arrayobject doesn't support cyclic garbage collection:

http://docs.python.org/c-api/gcsupport.html

@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

Milestone changed to Unscheduled by @pv on 2010-09-05

@thouis
Copy link
Contributor Author

thouis commented Oct 19, 2012

Title changed from Memory leak: objects not deallocated after using them in an array to Add cyclic garbage collection support to object arrays by @mwiebe on 2011-03-24

@charris
Copy link
Member

charris commented Nov 23, 2016

Closing in favor of more recent #6581.

@charris charris closed this as completed Nov 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants