Re: [AD] SF.net SVN: alleg:[14994] allegro/branches/5.1

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2012-04-22, at 1:48 PM, Evert Glebbeek wrote:
> I don't know whether this was discussed at some point or not (couldn't find anything when searching my mail though) but I'm guessing this is the reason I get tons of complaints of memory leaks printed to the console with 5.1. While I agree with the intention (memory leaks should be fixed, not hidden) I'm wondering whether the approach here doesn't take things too far.
> First of all, my understanding is that if you create your own threat then you *have* to create a release pool for it. Especially considering that some of the complaints I seem to be coming from Cocoa itself rather than objects Allegro creates and then leaves dangling, I suggest that we restore the release pool for the mangled main (see patch below) and drain it periodically (not sure how to do that though).
> 
> If I'm missing something and Allegro itself is actually leaking objects, does anyone have a suggestion for where to start looking for places where one might fix "Object of class NSPathStore2 autoreleased with no pool in place"?
> 
> Evert
> 
> Index: ../macosx/osx_app_delegate.m
> ===================================================================
> --- ../macosx/osx_app_delegate.m	(revision 15563)
> +++ ../macosx/osx_app_delegate.m	(working copy)
> @@ -221,8 +221,10 @@
>  */
> + (void)app_main: (id)arg
> {
> +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>     (void)arg;
>     call_user_main();
> +    [pool release];
> }
> 
> 
> @@ -260,6 +262,7 @@
> int _al_osx_run_main(int argc, char **argv,
>    int (*real_main)(int, char **))
> {
> +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>     AllegroAppDelegate *app_delegate = [[AllegroAppDelegate alloc] init];
>     NSMenu *menu;
>     NSMenuItem *temp_item;
> @@ -334,5 +337,6 @@
>     [NSApp run];
>     /* Can never get here */
>     [app_delegate release];
> +    [pool release];
>     return 0;
> }


I have to say I agree with the purpose of the change removing autorelease pools. And for someone who can reproduce those messages, it's easy to fix them. I haven't tried yet but Elias said he couldn't reproduce them or they'd be fixed already. IIRC you can set a breakpoint (the error message even tells you where to set it IIRC) and the backtrace will show exactly where the leak is coming from.

Trent



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/