Is there a .NET API for getting detailed info on VM use? I’m specifically interested in determining how fragmented my address space is.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The kind of Windows API functions that can give you some insight in this are VirtualQueryEx() to enumerate the virtual memory sections and discover unused space, GetProcessHeaps() to find what heaps are created inside the process and HeapWalk() to discover how blocks in each heap are used.
This is not going to be easy, particularly HeapWalk() is a troublesome function in a running program. You ought to take a look at the SysInternals’ VMMap utility, it provides excellent virtual memory diagnostics.
The downfall with this is that it doesn’t really help you solve a memory fragmentation problem. There is nothing you can do to affect the way the Windows memory manager sub-allocates the virtual memory space. Short from not allocating memory. If you are struggling now with OOM, you really ought to consider re-architecting your app. Or switching to a 64-bit operating system, the two hundred dollar solution.