2

I would like to use valgrind to detect leaks on iPhoneSimulator. I got the source for valgrind, compiled and installed. Added the following to my code


int main(int argc, char *argv[]) {

#ifdef VALGRIND_REXEC
    if (argc = 2 && strcmp(argv[1], "-valgrind") != 0)) {
        execl(VALGRIND, VALGRIND, "--leak-check=full", "--dsymutil=yes", argv[0], "-valgrind", NULL);
    }
#endif

VALGRIND_REXEC is defined, when I try to Debug or Run my application I get the following error in the console


[Session started at 2011-03-14 16:21:27 +0000.]
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
open$UNIX2003 called from function main in image valgrind.
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.

Mac 10.6.5 Xcode 3.2.5 iOS 4.2

Do I need to compile valgrind in any special way, what am I doing wrong?

Mario
  • 33
  • 1
  • 4

1 Answers1

0

Out of random curiosity, is there a reason the "Leaks" tool in Xcode won't do what you need it to?

Community
  • 1
  • 1
Simon Goldeen
  • 9,080
  • 3
  • 36
  • 45
  • Hi Simon, thank you for your comment. When trying to use Leaks from Xcode I get the error "Target failed to run". When running target from Instruments I get "Failure while acquiring malloc pointers (LeakAgent32)". Cannot use Leaks, hence looking for alternate solutions. – Mario Mar 14 '11 at 20:40
  • Build & Analyze is also pretty good at finding potential leaks. – Caleb Mar 15 '11 at 01:04
  • Valgrind does more than just memory leaks. It's a comprehensive memory-usage analyzer, tracking things like writes outside of allocated memory, reads of uninitialized values, and so on. – Mark Jan 31 '20 at 21:32