Re: Memory leak detection
Quote:
Originally Posted by
Sid
What kind of problems did you encounter? I gave it a quick try and it seems to detect at least basic and obvious leaks just fine. :)
Re: Memory leak detection
First of all, sorry for digging up such an old thread, but I figured it was better to continue this one than to make a new one.
I'm trying to implement memory leak detection in my debug exe and for that I'm using the memory leak detector linked to in the original poster's post. However, I don't get any ouput. I'm guessing this is because my application is a GUI and I have no console window.
I did some simple tests, like adding a "cout << "Test";" line to my app and if I run it like this from the command prompt: "testapp.exe > output.txt", it works just fine, console output gets written to output.txt upon exit. So, after thinking about complaining here for help I dug a little deeper ;).
First, I tried changing line 149 of debug_new.h to:
Code:
: _M_file(file), _M_line(line) { freopen("file_of_choice.txt", "w", new_output_fp); }
But, for some reason that didn't quite work. In case anyone knows why, feel free to let me know. I even added a cout test line in the constructor, but it doesn't seem to do anything, pretty weird.
The simple solution is to edit line 281 of debug_new.cpp and change "stderr" to "stdout", so you can redirect the output to a file by simple calling your program from console with program.exe > outputfile.txt.
If anyone knows a more graceful solution, let me know.
Ok, this is newbie stuff, but still, it might save someone some time.
Re: Memory leak detection
Enable console by adding
to .pro file and then re-build the application.
Re: Memory leak detection
Hm, that doesn't seem to work. When I add "console" I get an "undefined reference to 'WinMain@16'" error from libmingw32.a(main.o). Removing "windows" from CONFIG doesn't help either.
Re: Memory leak detection
Just rebuild the application:
Quote:
> make clean
> make
Re: Memory leak detection
Ah, ok, thanks, didn't know a rebuild required a make clean. It works now.
Re: Memory leak detection
I want to do the same, but it only shows the address of variable in memory, not the line of code:
Leaked object at 003E6D80 (size 4, 004013CA)
Leaked object at 003E6DE0 (size 10, 004013DA)
*** 2 leaks found
I understand there is program called addr2line for linux, but I'm on windows platform. How could I translate it?
Thanks!
Update: OK, i found it mingw32 folder. How should I use it on windows on executables?
I have tried this addr2line -e <app.exe> 00415B82 and without address, but no meaningful output, just these:
??:0
??:0
??:0
??:0
??:0
Re: Memory leak detection
OK, I should have used the debug version of the executable.... :rolleyes: