Do you maybe have any idea how "expensive" it is to open a handle on windows?
Because I'm wondering at what resolution I must take snapshot of my memory usage to see it change over time.(query memory usage every how many seconds?)
Thanks for your input, it really helped.
You're welcome, I'm please you found it helpful.
As far as how "expensive" it is to open a handle, I haven't tested the performance of OpenProcess and OpenThread but, going by what some utilities such as ProcessHacker and ProcessExplorer do - which is refresh process information at specific intervals of time - I am led to believe it isn't a very expensive operation.
A simple way to test it would be to use toolhelp to get a list of process ids and, open a handle for every id in a loop about 1000 times, that should give an idea. (remember to close the process handles... <chuckle>)
The default in ProcessHacker is to refresh every second. That seems to work reasonably well, it doesn't consume an inordinate amount of CPU. ProcessExplorer defaults to the same value and doesn't use much CPU either.
HTH.