From: Panayotis K. <pan...@pa...> - 2010-03-28 09:33:28
|
On 28 Μαρ 2010, at 12:13 μ.μ., Arno Puder wrote: > > it is actually interesting to note that Cocoa places quite a few objects > in the autorelease pool. If you comment out the creation of the one > autorelease pool in XMLVM's main() method, you will get a lot of > warnings of leaking objects. Since XMLVM no longer places objects in the > autorelease pool, these must come from Cocoa. As a matter of fact, all > so-called convenience methods where the object is not created via the > usual alloc/init (e.g., [NSString string*]), are placed by convention in > an autorelease pool. So the question is how to deal with that in XMLVM. > One suggestion would be to implement System.gc() so that it calls [pool > drain]. It would be the programmers responsibility to call System.gc() > from time to time. > > In case of the enumerator, since we know it is placed in the autorelease > pool, one could do a [pool drain] in the wrapper. > > Any other ideas? > > Arno I think I've seen in various places in the autorelease pool objects that are produced through "convenient" methods. So in any case, an auto-release pool should be always there and keep up with what would have happened when programming in obj-c. Code as usual, some objects will be on the autorelease pool, and when the specific even cycle ends, then the memory of these objects will return to the system. So I believe that there should be no special handling of enumerators. Of course to do some cleanup by overriding System.gc() , is not a bad idea ;) |