SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Memory leaks

From: Ken M. <mc...@ii...> - 2007年07月05日 20:20:48
On Jul 5, 2007, at 2:13 PM, Michael Droettboom wrote:
>
> Interesting. I don't get that, but I do get some random segfaults (I
> got lucky the first time I tested).
It looks like wxPython doesn't retain a reference to the wxApp PyObj 
for you:
	kmcivor@400exp209:~/Projects/matplotlib-svn$ pythonw
	Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
	[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import wx
	>>> app = wx.PySimpleApp()
	>>> del app
	>>> wx.GetApp()
	Segmentation fault
> I'm awfully surprised that wx.GetApp() would return an iterator, as 
> you
> are getting, so maybe it's corruption of some sort?
My guess is that Eric got lucky and ob_type was pointing to the 
listiterator's C type instance.
> Since I didn't want to just put the wxapp global variable back in, 
> I assigned it to the figure that creates it, therefore stick around 
> as long as the figure does. (Is that the correct thing for its 
> lifetime?)
I don't think this will work if you create two figures, destroy the 
first one, and then create another figure. Once created, the wxApp 
needs to exist for the life of the python process. I'll go ahead an 
put the global variable back in.
> Also, I'm a little puzzled by this code in show() in backend_wx.py:
>
> wxapp = wx.GetApp()
> if wxapp is not None:
> # wxPython 2.4 has no wx.App.IsMainLoopRunning() method
> imlr = getattr(wxapp, 'IsMainLoopRunning', lambda: False)
> if imlr():
> wxapp.MainLoop()
>
> If I'm reading this correctly, shouldn't it be "if not imlr()"?
Yes, it should be. I'll try to code with my eyes open from now on. :-/
Ken

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /