Skip to content
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

Run a memory checker with google test to find leaks #5

Open
rickBuczynski opened this issue Jun 13, 2018 · 2 comments
Open

Run a memory checker with google test to find leaks #5

rickBuczynski opened this issue Jun 13, 2018 · 2 comments

Comments

@rickBuczynski
Copy link
Owner

https://stackoverflow.com/questions/12704543/memory-leak-when-using-google-test-on-windows

@rickBuczynski
Copy link
Owner Author

At the top:

#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#include <stdlib.h>

above "namespace {":

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
// dummy run to force all gtest allocations
RUN_ALL_TESTS();

_CrtMemState memoryState = {0};
_CrtMemCheckpoint(&memoryState);

int retval = RUN_ALL_TESTS();
std::cout << "hello rick" << std::endl;

// Check for leaks after tests have run
_CrtMemDumpAllObjectsSince(&memoryState);

return retval;
}

@rickBuczynski
Copy link
Owner Author

Also need to remove EXPECT_EQ from tests that are running. That call seems to leak memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant