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

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


On 28 Aug 2011, at 15:17 , elias@xxxxxxxxxx wrote:
> - Removed some global pools we never drain - those serve no purpose except hiding leaks (more and more objects get added to the pool and are never freed (before program exit). Instead, memory must be released when not used any longer so the garbage collecttor will collect them.)

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;
 }





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