-
July 29th, 2020, 09:24 PM
#1
Memory leak detection
Hi,
I am developing an application which contains of a binary executable and couple of DLLs.
I do see that in some scenarios I have memory leaks. Since they are not good I want to fix them.
Googling pointed me to this. What I'd like to know is how to define this when the application have multiple DLLs.
1. Should I define _CRTDBG_MAP_ALLOC, only once in my main application start up or I need to define it on every DLL loading?
2. The same with the:
Code:
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
?
The application is a GUI one developed with wxWidgets, so it has 1 entry and 1 exit points.
Thank you.
-
July 30th, 2020, 05:04 AM
#2
Re: Memory leak detection
The following comment from the link leads me to believe _CRTDBG_ALLOC__MEM_DF only needs to be defined once.
"By default, _CrtDumpMemoryLeaks outputs the memory-leak report to the Debug pane of the Output window. If you use a library, the library might reset the output to another location."
If you are still in doubt, you can test for it by creating a memory leak in one of your DLLs and see if it spews to the output window.
-
July 30th, 2020, 09:05 AM
#3
Re: Memory leak detection
Hi,
It is not a matter of reporting the leak - I see it present.
What I'm after is the place where allocation occurs.
I tried to run VLD, but got a crash on the application start-up. So thought of trying with the MSVC way.
I just tried to put those 3 lines in the application constructor but didn't see any reports of the line numbers for where allocation occur.
I will try to place them in the every DLL initialization routine.
Thank you.
-
July 30th, 2020, 02:41 PM
#4
Re: Memory leak detection
Create a test solution with exe and dll projects, introduce leaks, and get it working there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|