Garbage collection

How is garbage collect done in wxPython? Is there a function or method call
that will perform garbage collection.
It appear that only when my app is minimized that garbage collection is
done. I would like to do it more often.

Frank Lynch
email: flynch27@comcast.net

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Wednesday, April 14, 2004 4:27 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] wxSizer.Remove() assert traceback

Brian Almond wrote:

I have a panel on which I'm creating controls dynamically. At times I
need to clean the slate, and I'm trying to employ the solution that's in
the wiki FAQ 3.10:

def removeChildren(self, destroy=1):
        """
        Remove all my children components and optionally
        destroy them.
        """
        while self.GetSizer().Remove(0):
            pass
        if destroy:
            self.DestroyChildren()

When I use this on my panel, it appears that instead of Remove(0)
returning a false if the item isn't found, it causes an assertion in the
wx core. Here's the traceback:

Try it like this:

     def removeChildren(self, destroy=1):
         sizer = self.GetSizer()
         while sizer.GetChildren():
             sizer.Remove(0)
         if destroy:
             self.DestroyChildren()

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

<flynch27@comcast.net> writes:

How is garbage collect done in wxPython? Is there a function or method call
that will perform garbage collection.

See Python's `gc' module.

And..., could you please avoid piggy-backing on unrelated threads like that?
It's really... bothersome....
Thanks :slight_smile:

Thanks Joshua. Sorry about the unrelated thread. I was rushing.

Frank Lynch
email: flynch27@comcast.net

···

-----Original Message-----
From: news [mailto:news@sea.gmane.org]On Behalf Of Joshua Judson Rosen
Sent: Friday, April 16, 2004 12:55 AM
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython-users] Re: Garbage collection

<flynch27@comcast.net> writes:

How is garbage collect done in wxPython? Is there a function or method

call

that will perform garbage collection.

See Python's `gc' module.

And..., could you please avoid piggy-backing on unrelated threads like that?
It's really... bothersome....
Thanks :slight_smile:

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

flynch27@comcast.net wrote:

How is garbage collect done in wxPython? Is there a function or method call
that will perform garbage collection.
It appear that only when my app is minimized that garbage collection is
done. I would like to do it more often.

There are a number of factors. Normally Python objects are cleaned up when their reference count drops to zero. Python's GC kicks in periodically to try and collect situations when there are unattached circular references, but I think that it doesn't work if there are references held from C++ objects... Then there is the memory allocated by the wx C++ objects themselves, and if all goes well then that is freed when the objects are deleted by whatever means. *But*, what you are probably seeing happening when you minimize your app is totally unrelated and is Windows moving parts of the app's process map out to virtual memory pages, since similar memory reduction often happens when minimizing non-Python apps too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!