> Hi all, I'm wondering if it's possible for memcheck to show the last place > that some memory was accessible before being leaked.
The current implementation of memcheck cannot do this. Reporting the location of the leak for each leak would take a major re-think of memcheck. It would be easier to report the location of only the *last* leak. (If there were 500 leaks then you could find them all by running the tool 500 times, fixing them one-by-one as you go. And if you couldn't fix a particular last leak at some point, then you would be stuck; the tool could not pinpoint any more leaks for you.) If allocation and freeing were "stable" with respect to re-running the program, then a two-pass procedure would be almost easy. (It would take *lots* of disk space, but it would be easy.) Unfortunately "stable" is not as common as one might hope. In your example below the difficulty lies in the code that has been elided by the ellipses "...". If there are any assignments of x to other pointers, or if x is passed as an actual argument of a function call, then it is hard to determine whether a leak occurs. > > int* g() { > int* x = new int[256]; <-- allocated here > ... > return x; > } > > int f() { > int* x = g(); > ... > return 0; <-- leaked here > } > -- ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_feb _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users