What are these memory leaking objects, detected by

2019-05-29 03:54发布

问题:

I have an iPhone app, that seems to have memory leaking problem. It's a puzzle game, after a few puzzles, the app crashes on devices.

I'm now trying to use xcode Instruments to detect what's going on. First time to use Instruments.

I noticed a leak bar in the "Leaks" plot, right the time when the view is loaded. I copied the leaked objects below.

Leaked Object   #   Address Size    Responsible Library Responsible Frame
__NSTimeZone    1   0x1f87cfc0  32 Bytes    CFNetwork   _CFGregorianDateCreateWithBytes
icu::OlsonTimeZone  1   0x1f1a9a00  1.00 KB CFNetwork   PACEntryStreamCallback(__CoreReadStream*, unsigned long, void*)
icu::OlsonTimeZone  1   0x1f881850  128 Bytes   CFNetwork   PACEntryStreamCallback(__CoreReadStream*, unsigned long, void*)
icu::OlsonTimeZone  1   0x1f8817d0  128 Bytes   CFNetwork   PACEntryStreamCallback(__CoreReadStream*, unsigned long, void*)
icu::OlsonTimeZone  1   0x1f1a7a00  1.00 KB CFNetwork   PACEntryStreamCallback(__CoreReadStream*, unsigned long, void*)
__NSTimeZone    1   0x1f87d010  32 Bytes    CFNetwork   _CFGregorianDateCreateWithBytes

My app continues to work, with no additional leaked objects found. After a few round of puzzles, it crashed. I'm not sure it's related to the leaked objects shown above. My guess is there are other problem, but I think I need solve these leaked objects first.

Looks to me, the leaked objects are date/time related. I tried to commented out date/time related lines, but I still got the same leaked objects. Anybody knows what other stuff I should check what these leaked objects are? TIA!

回答1:

Just ignore all leaks which do not belong to your applications. Neither Instruments nor IOS / frameworks is not perfect. You should focus only on this leaks which are discovered in your own classes. To discover source of memory issues in application:

1) Enable NSZombieEnabled mode in Schema editor --in this case Instruments will be more informative.

2) Use Product->Analyze facility in Xcode -- Xcode will show to you suspected places in the source code.