• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Memory management issues/leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Memory management issues/leaks (From: PCWiz <email@hidden>)

  • Prev by Date: Re: Read last x bytes of a text file?
  • Next by Date: Re: int to bytes(value in NSString)
  • Previous by thread: Memory management issues/leaks
  • Next by thread: Custom grid view
  • Index(es):
    • Date
    • Thread