[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Python binding memory management code

From: Garrett Rooney <rooneg_at_electricjellyfish.net>
Date: 2005-10-20 22:14:04 CEST

On 10/20/05, David James <james82@gmail.com> wrote:

> The Python/SWIG bindings definitely need better documentation. This is
> an important item on our TODO list.
> The new code in proxy_apr.swg is designed to "mark pools as invalid"
> when their parent pools have been garbage collected. I implemented
> this trick by registering a callback with the Python garbage
> collector, so that we can be notified when the parent pool is deleted.
> See below:
> self._weakparent = weakref.ref(self._parent_pool._is_valid,
> lambda x: _mark_weakpool_invalid(weakself))
> When the "self._parent_pool._is_valid" object is deleted, Python calls
> the _mark_weakpool_invalid function. The _mark_weakpool_invalid
> function marks the current pool as "destroyed", because its parent has
> been destroyed.
> Pools can be destroyed in one of three ways:
> pool.destroy()
> pool.clear()
> pool.__del__() (Called by Python garbage collector)
> All of the above functions destroy the "_is_valid" member object, thus
> triggering the _mark_weakpool_invalid function for all children. If
> the child pool has already been destroyed when the
> _mark_weakpool_invalid function is called, then the
> _mark_weakpool_invalid function does nothing.
> Garrett, does this explanation help?

Thanks! Everything is much more clear now. I'll try to turn your
email into a nice comment in proxy_apr.swg, so the next person who
tries to understand this stuff has an easier time than I did ;-)


To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Oct 20 22:15:32 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.