for (auto _ : state) {
// check for memory allocation in process()
SAVE_MEM_STATE(s1inner);
// This code gets timed
benchmark::DoNotOptimize(
x += iap->process(data)
);
SAVE_MEM_STATE(s2inner);
ASSERT_NO_ALLOCS(s1inner, s2inner);
}
I'm using the _Crt* tools in MSVC to detect memory allocations in the process function for realtime purposes. Maybe there is a simple way to prevent the memory allocation at the end of the for loop so I can move the allocation detection macros outside of the loop? (when '__' goes out of scope?)
For clarification, the following creates memory snapshots that show an allocation has happened:
int x = 0;
_CrtMemState _s1, _s2;
for (auto _ : state) {
//// This code gets timed
//benchmark::DoNotOptimize(
// x += iap->process(data) + 1
//);
_CrtMemCheckpoint(&_s1);
}
_CrtMemCheckpoint(&_s2);
assert(_s1.lTotalCount == _s2.lTotalCount); // fails
Can you perhaps at least tell us what particular allocation is in question here,
by using debugger and placing breakpoint on the allocation function or something?
I'm using the _Crt* tools in MSVC to detect memory allocations in the process function for realtime purposes. Maybe there is a simple way to prevent the memory allocation at the end of the for loop so I can move the allocation detection macros outside of the loop? (when '__' goes out of scope?)
For clarification, the following creates memory snapshots that show an allocation has happened: