Re: autorelease pool page corrupted
Jake Wang <[email protected]> Tue, 29 Oct 2013 10:03:31 +0800
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <CALtF253OV7v0Ei88OMVQwG2Cxk10BKBojMa6jzprBzyuK+GYAg@mail.gmail.com> |
Hi Diez, Thanks for your sample code, which is really helpful. Please find my sample code as attached. Entrance script: test_wx_and_event_2.py Thread 1 - the main thread Thread 2 - user_event.EventHandlingThread It is slightly different, because only the first thread (the main thread) has PyObjc code, the second thread just shares an event queue with the first thread. After I added auto release code in the second thread, I got a new error: objc[1488]: Object 0x10791bf50 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug Also got the system error when quitting the app. Thanks, Jake On Sun, Oct 27, 2013 at 2:45 PM, Diez B. Roggisch <[email protected]> wrote: > > > On Oct 27, 2013, at 3:35 AM, Jake Wang <[email protected]> wrote: > > Hi Diez, > > Thanks for your reply and links, I tried some auto release code in the > sample code (https://github.com/jiakuan/wx-sample), but still no luck. > > > I don't see it, can you show it to me? > > > > I tried to replace the following code: > > def OnUnexpectedExit(event): > # > # Event handler that deals with the unexpected close event. > # > wx.GetApp().ExitMainLoop() > > to this: > > def OnUnexpectedExit(self, event): > # > # Event handler that deals with the unexpected close event. > # > sys.exit() > > Then no such error any more. I guess the issue was related to wxPython > with PyObjc in some way. > > > I'm not sure if that's a good solution. There are a *lot* of possibilities > here, and under normal circumstances, whatever you do in a user-space > program shouldn't cause problems for the OS. However, the rather "rude" way > of terminating a program you chose here might have just push the problem > from your logging output to the system log's output, because some > application cleanup hasn't been performed. This is just guessing, but a > check couldn't hurt. > > What you *must* verify though is that the lack of autorelease-pool doesn't > introduce garbage over time. > > I created the attached program to simulate that. You can ignore most of it > of course, but if you put a call to "garbage_producer" with e.g. a million > bytes as argument into your event handler, you should be able to see in the > activity monitor if the process grows in size. > > If so, you have to use a pool. > > > > The reason why we choose PyObjc and wxPython is that we want to use Python > language to share the majority of business logic on both Mac OS X and > Windows. The platform-dependent requirement is a relative small part, which > only contains global events listening, and a system tray icon (this code > can be shared on both Mac and Windows too). > > Any better solutions? > > > Better is relative. I personally would *never* go with wx, as it's not > good in looks as well as API. If being cross-platform was justified for me > enough (meaning the UI was sophisticated enough so that developing it > natively would be a major effort), I'd be using Qt, and one of it's > available bindings. > > Of course, these are matters of taste. I just suggest exploring the > alternatives. > > Diez > > ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ Pyobjc-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
wx-sample.zip
(application/zip, 320.8 KB) - not displayed