2

The _CrtMemState struct returned by _CrtMemCheckpoint() includes a size_t lHighWaterCount member which gives the maximum memory usage since the application started. I'm writing a testing rig which cares about high water marks, but it runs several tests during a single run, and I can only reliably get a high water mark for the first test: if the high water mark doesn't go up during the second test, I only know that the high water mark was less than or equal to that of the first test.

Is there any way to reset the CRT debug heap's high water mark to the current allocation size?

2

1 Answer 1

2

No, there is no way to reset this counter.

Consider an alternative solution: Register an allocation hook (via _CrtSetAllocHook) at the beginning of each test, keep your own high water count for the duration of that test, then unregister your hook at the end of the test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.