On 3/2/12 3:24 AM, Nathann Cohen wrote:
In general (not just Cython) a Python object is deallocated as soon as
it's no longer referenced (via the Py_DECREF macro), which is often as
soon as they fall out of scope. The garbage collector is used to
reclaim cyclically-referenced objects. Note also that ipython (used at
the Sage prompt) also keeps a lot of references to old results around,
making it difficult to do such analysis at the command line.

Hmmm.... So you mean that the object that is only used inside of the
function and does not get deallocated may be cyclically referenced ?
Is there any way to know who has a reference toward him ?

Hey !!!! Actually, you are right !! When you are using an Linear
Program in Sage you also define variables ! Variables point toward the
LP object, and the LP object points toward the variables... Is that
the cycle I should get rid of so that the LP object are deallocated as
soon as the function ends ???

But that would be messy.... :-/

I think weak references are the typical answer to a situation like this.

http://docs.python.org/library/weakref.html

http://docs.cython.org/src/reference/extension_types.html#weak-referencing

And thanks for working on this. I have a friend that was computing things like the chromatic number on all graphs of 10 vertices, and it was crashing because memory usage kept climbing.

Jason



--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to