suriel
suriel

Reputation: 341

Memory leas when upgrading to Visual Studio 2019

I recently upgraded our projects from VS2010 to 2019 which works pretty well, but hen runningit under the Debugger I get a lot of memoryleaks on finish. Of course they where not there in VS2010. All of my sources are build with

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

But the dump of the leaks kinda looks like this:

[16300] Detected memory leaks!
[16300] Dumping objects ->
[16300] {64582} 
[16300] normal block at 0x06210D00, 16 bytes long.
[16300]  Data: <   z   z        > FC 8B AD 7A 18 8C AD 7A 01 00 00 00 80 DC 1C 06 
[16300] {64581} 
[16300] normal block at 0x06210E00, 16 bytes long.
[16300]  Data: <   z   z    0   > FC 8B AD 7A 18 8C AD 7A 01 00 00 00 30 D5 1C 06 
[16300] {64580} 
[16300] normal block at 0x062109C0, 16 bytes long.
[16300]  Data: <   z   z        > FC 8B AD 7A 18 8C AD 7A 01 00 00 00 E8 CB 1C 06 
[16300] {64579} 
[16300] normal block at 0x06210780, 16 bytes long.
[16300]  Data: <   z   z        > FC 8B AD 7A 18 8C AD 7A 01 00 00 00 90 C6 1C 06

This continues for about 5700 mor lines ;-(

I already checked memory- and handle-consumtion: both are ok. I tried to use tools like MemPro (says no leaks), Dr. Memory (crashes) and Visual leak detector, which says

[16300] No memory leaks detected.
[16300] Visual Leak Detector is now exiting.

after the leaks-dump ...

Is it likly that I had the leaks in VS2010 already but they where not found/reportet? I don't think so?

So are there any hints to start searching for it?

Upvotes: 0

Views: 545

Answers (2)

suriel
suriel

Reputation: 341

DeLeaker did the trick and helped my finding the Leaks. After all I found some .cpp-files, that had NOT set #define new DEBUG_NEW. After fixing that, finding the problem was quite easy. Thank you for your help, Artem Razin

Upvotes: 1

Mr Qian
Mr Qian

Reputation: 23760

Is it likly that I had the leaks in VS2010 already but they where not found/reportet? I don't think so?

So are there any hints to start searching for it?

Since VS2017, VS has a decent memory analysis tool which can be used to find memory leaks.

When you debug your project in VS2019(remember to set a breakpoint), open Debug --> Windows --> Show Diagnostic Tools--> pick memory usage

Then debug the code, when the breakpoint is hit, click Take snapshot on the Memory Usage window.

After that, you can click on the icon to enter into the analysis of the memory and you can find the problem.

enter image description here

You can also refer to one official document and two official document to get the tips.

=========================================

Besides,you can also use the CRT library to find memory leaks.

Upvotes: 1

Related Questions