#12313: Fix yet another memory leak caused by caching of coercion data
--------------------------------------------------+-------------------------
Reporter: SimonKing | Owner:
Type: defect | Status:
needs_review
Priority: major | Milestone: sage-5.3
Component: memleak | Resolution:
Keywords: coercion weak dictionary | Work issues:
Report Upstream: N/A | Reviewers: Simon King,
Jean-Pierre Flori, John Perry
Authors: Simon King, Jean-Pierre Flori | Merged in:
Dependencies: #11521, #11599, #12969, #12215 | Stopgaps:
--------------------------------------------------+-------------------------
Comment (by SimonKing):
Replying to [comment:125 nbruin]:
> Does the line
> {{{
> return <object>PyList_GET_ITEM(bucket, i+1)
> }}}
> increase a refcount on the object we retrieve?
Here is another evidence that <object> does what we need:
{{{
sage: cython("""
....: def test(size_t k):
....: K = <object><void *>k
....: print K
....: del K
....: """)
sage: class A(object): pass
....:
sage: a = A()
sage: test(id(a))
<__main__.A object at 0x44a17d0>
sage: a
<__main__.A object at 0x44a17d0>
sage: del a
sage: import gc
sage: _ = gc.collect()
sage: quit
Exiting Sage (CPU time 0m0.16s, Wall time 0m39.96s).
}}}
If the reference count of the A-instance would not be increase by the
<object> cast in the test function, I guess a segfault would result,
wouldn't it?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12313#comment:149>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.