Sneftel
Sneftel

Reputation: 41484

Reset high water count in CRT debug heap

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?

Upvotes: 2

Views: 259

Answers (1)

James McNellis
James McNellis

Reputation: 355079

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.

Upvotes: 2

Related Questions