0

Checking my code for leaks using Instruments, i'm getting one show up that I can't figure out the solution for. It's this:

Malloc 48 bytes Responsible library - libsystem_c.dylib Responsible frame - strdup

I've googled this and a few suggestions tell people just to leave it, but submitting to Apple with a leak seems like a stupid thing to do, so I wanted to see if anybody could tell me more about this, or where it could be coming from?

Andrew
  • 15,935
  • 28
  • 121
  • 203
  • I assume that your code does not call `strdup` directly, right? – Sergey Kalinichenko Jun 14 '12 at 03:47
  • Did you try looking at the whole frame? You should be able to open the stack trace drawer to the right and have it show you the entire call stack for each leak. – gaige Jun 14 '12 at 04:22
  • This is a really well-known leak in Apple's code. It isn't your fault. Previous questions about it: [one](http://stackoverflow.com/questions/10512793/blocks-inside-nsmutablearray-leaking-arc), [two](http://stackoverflow.com/questions/9762995/memory-leak-every-time-uiscrollview-is-released). – Kurt Revis Jun 14 '12 at 04:34

1 Answers1

0

If your code doesn't use strdup() directly, then there are basically two possible reasons for the memory leak to be shown:

  1. Apple's code has a bug: it calls strdup() but doesn't free its return value after use.
  2. The debugging tool (Instruments or a command line tool called by it?) you're using falsely detects the memory leak.

In both case, you can file a bug report to Apple.