Re: "Help needed - I don't understand how Python manages memory"



http://trac.edgewall.org/ contains at least one example of a reference
leak. It's holding up the release of 0.11 for a while. *scnr*

All my investigations on possible memory leaks in Trac have only
confirmed that Python does _not_, I repeat, it does *NOT* leak any
memory in Trac.

Instead, what appears as a leak is an unfortunate side effect of
the typical malloc implementation which prevents malloc from returning
memory to the system. The memory hasn't leaked, and is indeed available
for further allocations by trac.

The problem is also covered by the docs at
http://docs.python.org/dev/library/sys.html#sys.exc_info

Ah, but that's not a *reference* leak. If Python (or an extension
module) contains a reference leak, that's a bug.

A reference leak is a leak where the reference counter is increased
without ever being decreased (i.e. without the application having
a chance to ever decrease it correctly). In this case, it's just a
cyclic reference, which will get released whenever the garbage
collector runs next, so it's not a memory leak.

Regards,
Martin
.



Relevant Pages

  • Re: MDAC memory leak
    ... Most libraries place the decision of when to free ... There's a capability of breaking on a particular memory allocation, ... leak 500 objects, on the second test I leak 3, because I fixed the bug). ... "App shows memory leak on some machines." ...
    (microsoft.public.vc.mfc)
  • Re: Memory leak or expected behavior?
    ... >each web page bump the memory out, and as we know it's not given back ... My experience with objects 'leaking' memory (not a true leak, ... In Tk you need to reuse objects, because it keeps a reference to ... photo objects to handle what will be on-screen at any one time. ...
    (comp.lang.perl.misc)
  • Re: MDAC memory leak
    ... Also when we used some of the memory leak tools suggested on microsoft site ... A mutex is a considerably less efficient synchronization ... "App shows memory leak on some machines." ...
    (microsoft.public.vc.mfc)
  • Re: GC.Collect can be trusted?
    ... The problem you are describing is not a real "memory leak", the problem is that you don't know who's keeping a reference to the object, so you aren't able to release the object by setting it's reference to null, this is an application bug disguised as a leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help! define_method leaking procs...
    ... >>> VmSize value. ... there is no evidence yet that ruby is not ... I am not saying there is no memory leak ...
    (comp.lang.ruby)