Re: [Pyobjc-dev] autorelease pool page corrupted
Brought to you by:
ronaldoussoren
From: Diez B. R. <de...@we...> - 2013-10-27 06:45:44
|
On Oct 27, 2013, at 3:35 AM, Jake Wang <del...@gm...> 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 |