Re: Memory management issues/leaks
Re: Memory management issues/leaks
- Subject: Re: Memory management issues/leaks
- From: Quincey Morris <email@hidden>
- Date: Mon, 17 Aug 2009 22:29:10 -0700
On Aug 17, 2009, at 15:15, PCWiz wrote:
I have an Objective-C/Cocoa app with garbage collection enabled. To
check for memory leaks I first ran it through Instruments and it did
find some leaks. There was no information on where the leaks were
coming from, so I used another tool, AnalysisTool (basically a front
end for the Clang Static Analyzer) to check my code for memory
issues. It found some leaks and I fixed all of them, however
Instruments still reports leaks.
Further complicating the problem is that my app crashes when garbage
collection is disabled. And in the Xcode debugger console (when
garbage collection is enabled), right when my app starts I get these
errors:
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x101bfb0, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x101ec90, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x1021560, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x1027da0, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x10293f0, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x102a2a0, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x102cd00, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x1030e70, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x1032bf0, has non-zero refcount = 1
MyApp(9874,0xb0103000) malloc: free_garbage: garbage ptr =
0x1033430, has non-zero refcount = 1
a. These error messages are well known and perfectly harmless, though
annoying. You get them in a GC app when you use the system-supplied
images that IB shows in its Library Media tab. The fix is popularly
believed to be coming in Snow Leopard.
b. You *cannot* safely disable garbage collection in an app unless
you've intentionally written it using retain/release. With GC off, and
no retain/release code, your app is certainly going to crash.
c. Instruments is known to be wrong about reporting leaks under
Leopard. It's probably not worth trying to deduce any useful
information from it, so unless you know form other evidence that you
have a problem with leaks, I'd suggest you just don't bother looking
for them. A fix to Instruments is popularly believed to be coming in
Snow Leopard.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden