views:

34

answers:

2

Hello I turned on garbage collection (objective-c 2.0) and the image for the status item disappeared when I restarted my application.  I am manually memory managing the image and status item.  This application works normal when garbage collection is off.  Is there a way to make the garbage collection not collect specific variables or should I turn it off completely?

I tried garbage collection and found that my application uses about 2 mb of memory compared to 100mb, so that is why I considered using it.

+1  A: 

How are you "manually managing the memory of the image and status item"? If you are using release and retain, they are actually ignored under GC.

Under GC, objects stick around if (a) you have a strong reference to them in GC scanned memory or you (b) CFRetain them.

bbum
+1  A: 

Just keep a reference to it as an instance variable of some object e.g. the controller of the view it appears in.

JeremyP
Can you show me and example of how I could do that? That would be good :)
alexy13