iOS libsystem_c.dylib strdup memory leak NSZombie not working

一笑奈何 提交于 2019-12-03 09:51:35

问题


Please help me track down an iOS memory leak. Thanks!

I'm using xCode 4.0.1 and I tried to activate NSZombie to track a memory leak, but it doesn't seems to work as before, with xCode 3.x

I can't find out where the memory leak is coming from, as Instruments points this out:

Leaked Object -> GeneralBlock-32 Address -> 0x4c8600 Size -> 32 Bytes Responsible Library -> libsystem_c.dylib Responsible Frame/Caller -> strup

At this point I don't know If I'm using Instruments with NSZombie the right way with xCode 4, as it doesn't show the NSZombie option when I click "i" for more information, under the left option Leaks.

OBSERVATION: My iPhone application plays a live stream mms/wma and also wma áudio files with a finite amount of time. The leak happens only with a finite wma file, but runs perfectly when I'm playing from a streamed source, with no ending time.


回答1:


First, that is a malloc block, not an object. Zombies won't work (and would never have worked in prior versions either).

How many times does that leak happen? Once? Don't worry about it. Once per stream? file a bug -- that isn't in your code from what you have posted so far (unless your code is calling strdup, which is certainly possible but atypical in most iOS apps that aren't making heavy use of third party libraries... are you?)

In any case, unless it is leaking 100s and 100s of 32 byte allocations across the runtime of your app, don't worry about it (but please do file a bug).

As Valkio said, you can grab the stack trace of the allocation from gdb (or from Instruments) directly.




回答2:


You can see where it was allocated if you do this:

  1. Go to Product -> Edit Scheme -> Run (Debug) -> Arguments.
  2. Add this to environment variables: MallocStackLoggingNoCompact
  3. Set it to YES
  4. Run, and let it crash.
  5. type in console (gdb) info malloc 0x4c8600 or whatever the address is.


来源:https://stackoverflow.com/questions/5899419/ios-libsystem-c-dylib-strdup-memory-leak-nszombie-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!