How to ignore false positive memory leaks from _CrtDumpMemoryLeaks?

后端 未结 7 1287
[愿得一人]
[愿得一人] 2020-12-03 11:41

It seems whenever there are static objects, _CrtDumpMemoryLeaks returns a false positive claiming it is leaking memory. I know this is because they do not get destroyed unti

7条回答
  •  盖世英雄少女心
    2020-12-03 12:24

    Not a direct solution, but in general I've found it worthwhile to move as much allocation as possible out of static initialization time. It generally leads to headaches (initialization order, de-initialization order etc).

    If that proves too difficult you can call _CrtMemCheckpoint (http://msdn.microsoft.com/en-us/library/h3z85t43%28VS.80%29.aspx) at the start of main(), and _CrtMemDumpAllObjectsSince at the end.

提交回复
热议问题