c++ - PROCESS_MEMORY_COUNTERS_EX creates unreliable PrivateUsage field, why? -


using following code on vs 2012, native c++ development:

size_t cppunittests_memoryvalidation::takememoryusagesnapshot() {       process_memory_counters_ex processmemorycounter;     getprocessmemoryinfo(getcurrentprocess(), (process_memory_counters*)         &processmemorycounter, sizeof(processmemorycounter));     return processmemorycounter.privateusage; } 

i call method before , after each cppunittest , calculate difference of privateusage field. difference should zero, assuming memory allocation doesn't leak.

only simple things happen inside test class. without memory allocation, creating instance of test class , releasing again, (not in every test iteration) difference gets above zero, scheme seems non-deterministic.

is there more insight me either explain how tackle or tell me wrong assumptions?

in short, assumptions not correct. there can lot of other things going on in process perform memory allocation (the event tracing thread, , others created third-party add-ons on system) not surprising see memory use go occasionally.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -