|
|
 | | From: | Pierre Chatel | | Subject: | autorelease | | Date: | Thu, 9 Dec 2004 13:33:59 -0500 |
|
|
 | hello,
i'm having a hard time trying to understand the whole memory management system with cocoa (first langage with ref counting i'm using). And especialy how and when autorelease is releasing an oject... In "The Objective-C programming Language" from Apple they are talking about the "application object" (cf page 144, "Marking 0bject for Later Realease") what's is that exactly ? The fact that english is not my native language doesn't help :-) Could u point me to ressources on the web talking about this subject (even if it's in english :-))
Pierre
|
|
 | | From: | Kinou | | Subject: | Re: autorelease | | Date: | Fri, 10 Dec 2004 10:09:22 +0100 |
|
|
 | Pierre Chatel wrote: > hello, > > i'm having a hard time trying to understand the whole memory management > system with cocoa (first langage with ref counting i'm using). And > especialy how and when autorelease is releasing an oject... In "The > Objective-C programming Language" from Apple they are talking about the > "application object" (cf page 144, "Marking 0bject for Later Realease") > what's is that exactly ? The fact that english is not my native language > doesn't help :-) > Could u point me to ressources on the web talking about this subject > (even if it's in english :-)) > > Pierre >
Hello,
There is an article here : http://www.projectomega.org/article.php?lg=fr&php=oreilly_cocoa9&p=1
That's in french, so sorry for the others, but Pierre seems to be french ;) I think that the article can be found on the oreilly website in english. I'm french too, so sorry for my poor english.
Pierre, je ne sais pas si tu connais ce site, mais ils traduisent beaucoup des articles oreilly sur Cocoa, et c'est une petite mine d'or ! Amuse toi bien.
-- Regards, Vincent
|
|
 | | From: | Pierre Chatel | | Subject: | Re: autorelease | | Date: | Fri, 10 Dec 2004 13:00:24 -0500 |
|
|
 | On 2004-12-10 04:09:22 -0500, Kinou said:
> Pierre Chatel wrote: >> hello, >> >> i'm having a hard time trying to understand the whole memory management >> system with cocoa (first langage with ref counting i'm using). And >> especialy how and when autorelease is releasing an oject... In "The >> Objective-C programming Language" from Apple they are talking about the >> "application object" (cf page 144, "Marking 0bject for Later Realease") >> what's is that exactly ? The fact that english is not my native >> language doesn't help :-) >> Could u point me to ressources on the web talking about this subject >> (even if it's in english :-)) >> >> Pierre >> > > Hello, > > There is an article here : > http://www.projectomega.org/article.php?lg=fr&php=oreilly_cocoa9&p=1 > > That's in french, so sorry for the others, but Pierre seems to be french ;) > I think that the article can be found on the oreilly website in > english. I'm french too, so sorry for my poor english. > > Pierre, je ne sais pas si tu connais ce site, mais ils traduisent > beaucoup des articles oreilly sur Cocoa, et c'est une petite mine d'or > ! Amuse toi bien.
merci Kinou, ca a l'air trés bien :-)
|
|
 | | From: | David Stes | | Subject: | Re: autorelease | | Date: | Thu, 09 Dec 2004 21:43:14 GMT |
|
|
 | Pierre Chatel wrote: > hello, > > i'm having a hard time trying to understand the whole memory management > system with cocoa (first langage with ref counting i'm using).
I'm not surprised, since it's not a very good memory management.
Besides, it is not related to the "language" but rather to that specific toolkit for building GUI's.
> And especialy how and when autorelease is releasing an oject...
Autorelease is a way to keep a list of all objects that at some later time should be released. "Later" is at the end of an event loop, for instance. It is GUI (event loop) specific,and not really suited for general programming.
There was also a time that the pool was released periodically (every x seconds, but that of course doesn't work at all).
> In "The > Objective-C programming Language" from Apple they are talking about the > "application object" (cf page 144, "Marking 0bject for Later Realease") > what's is that exactly ?
The 'application object' is your object. As said, the terminology is rather GUI specific, and the memory management is really specific for GUI's and not for general Objective-C programming.
The 'application object' is the instance of your class that is in your 'application' which is an Objective-C program that is assumed to be a GUI program.
> The fact that english is not my native > language doesn't help :-) > Could u point me to ressources on the web talking about this subject > (even if it's in english :-))
There's tons of discussions on the subject, but essentially it is simply a badly written and badly designed memory management.
|
|
 | | From: | Sherm Pendley | | Subject: | Re: autorelease | | Date: | Thu, 09 Dec 2004 17:35:50 -0500 |
|
|
 | David Stes wrote:
> It is GUI (event loop) specific,and not really suited for general programming.
I don't know where you got that - NSAutoreleasePool is part of Foundation, and perfectly usable in a command-line tool.
In fact, if you're using Apple's Xcode and create a "Foundation tool" project, the template main() function includes code to create a pool at the beginning and release it at the end.
> The 'application object' is your object.
Not true. Apple's docs here are referring to the singleton instance of NSApplication. That's the object that manages the GUI event loop. Each time through the loop, it creates an autorelease pool, fetches an event, processes it, and then releases the pool.
> the memory management is really specific for GUI's and not > for general Objective-C programming.
Not at all. Cocoa automatically provides an autorelase pool for each GUI event, but that's certainly not the only way to use it.
sherm--
-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
|
|
 | | From: | Michael Ash | | Subject: | Re: autorelease | | Date: | Thu, 09 Dec 2004 13:08:11 -0600 |
|
|
 | Pierre Chatel wrote: > hello, > > i'm having a hard time trying to understand the whole memory management > system with cocoa (first langage with ref counting i'm using). And > especialy how and when autorelease is releasing an oject... In "The > Objective-C programming Language" from Apple they are talking about the > "application object" (cf page 144, "Marking 0bject for Later Realease") > what's is that exactly ? The fact that english is not my native > language doesn't help :-) > Could u point me to ressources on the web talking about this subject > (even if it's in english :-))
I would recommend this article:
http://www.stepwise.com/Articles/Technical/HoldMe.html
For a more in-depth overview, there are lots of good articles here:
http://www.cocoadev.com/index.pl?MemoryManagement
Cocoa memory management is incredibly simple once you get it, but for some reason it can take a while to "click".
|
|
|