I am automating some profiling tasks and want to log heap space and generation sizes real-time. The profiling API seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which isn't that important to me. Profiling tools are a great help of course, but I was looking for a more flexible, programmable interface.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
The term 'current memory usage' is a little loosely defined. Do you mean the working set? Whatever it means, you can use different properties such as
VirtualMemorySize
,WorkingSet
,PrivateMemorySize
, etc. from the process class to retrieve it.Once I had to find a memory leak in a legacy code, I came accross this solution: Start "tasklist" with appropriate parameters as a process and read the output either from stream or from file.
e.g.
Output is:
Not that elegant, but works in any programming language on Windows without additional dependences (C++/Qt in my case).
There are performance counters for a lot of this stuff and if you can't use Perfmon, you can access counters through the Diagnostics API.