New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory leaks detected by MSVCRT debugging facilities #1112
Comments
Just an additional note:
|
There should be no leaks in Catch, and under Linux we run CI with Valgrind. We also support the crt debug heap, just define Anyway, I tried to reproduce this and I cannot:
|
crtdbg routines are debug build diagnostics. You will need a debug build. Anyway, to confirm I also tested building from the commandline:
Then drag into VS for debug session Updated source file edit: |
I'm fairly sure I've fixed this now (but not been able to test on Windows). I recently added another singleton (I know, I know!) and forget to add it to the clean-up call. |
No, sorry I still get a dump from both end of main and the silly instance destructor |
I should have mentioned, btw, that my fix is not (yet) present in the single include - so you'd need to regenerate that ( |
BTW you shouldn't need to explicitly call |
Sorry, correcting myself, Catch only does leak detection if you define |
Calling _CrtDumpMemoryLeaks() is just routine and was actually my initial question, if Catch generate a false indication due to late memory release. My "silly me" test was a try to confirm that. Well, I'll try to generate a new header and see if it went away edit:
|
Updated singleheader and still get memory dumps |
🤔 |
To be sure, please generate a confirmed single header and push it to git. |
there's no difference with how you declare a custom main in the full project vs the single header, but note the full project now includes cpp files. |
I get |
you should just need to do the usual, |
Right, that's quite a list if I understand it correctly
|
Yes, at a glance that looks about right. |
I tried to locate the line where the reported memory is allocated according to
as mentioned before, this will clash against
Not sure how to proceed |
I've never been very satisfied with the |
I changed to MTd (see MSDN comments), I get
So setting a breakpoint at allocation number 106 => no effect for me |
Probably it's too early (usually happens if it's from a static constructor that gets called before main). |
(sorry for vagueness, it's a couple of years since I've had to do that) |
Still think it would be good to get the |
This occurs for me with Catch 2.01 single header and Visual C++ 2017.6.4. Plugging the allocation number into _crtBreakAlloc breaks on line 9546 of catch.hpp: Its not really a problem here - I'll just switch to later dumping of leaks after global tear-down by using @BeErikk : there is a technique described on stackoverflow for setting the allocation breakpoint early so it can catch allocations made before main. |
I guess this should be already fixed by #1411 |
@JoeyGrajciar It both is, and isn't. 1411 moves the final release point forward a bit, but you will still get false positives if you try to check allocations before |
Extra information
Environment: Windows 10
Compiler: Microsoft (R) Compiler Version 19.11.25547 for x64 (VS2017 15.4.4)
Compiler options:
-sdl -guard:cf -Zc:inline -Zc:rvalueCast -Zc:referenceBinding -Zc:strictStrings -std:c++latest
Version of Catch: Current master git source
Description
I've just started with Catch and I created a test project following code as described in the
Catch2/docs/tutorial.md
. I added the#define CATCH_CONFIG_RUNNER
and implemented my own wmain, basically a copy of the default. I also added the_CrtDumpMemoryLeaks()
diagnostics in the end of wmain. I get the following output:Is it possible this could be a false indication of memory allocated by Catch waiting to be released at program exit? If so, is it by design?
Steps to reproduce
Compile the source file
catch_tutorial.cpp.txt
The text was updated successfully, but these errors were encountered: