This is a mirror of official site: http://jasper-net.blogspot.com/

What is your computer doing with all that memory? Write your own memory browser

| Wednesday, December 1, 2010
What is your computer doing with all that memory? There are various kinds of memory allocated and used in each process. These include:
·         Managed memory (VB.Net, C#, managed C++)
·         Heap memory
·         Stacks
·         Images (files loaded into a process)

VirtualAlloc is the basis of these allocations. If a process needs more of these types of memory, VirtualAlloc is called.

You can inspect the various kinds of memory by running the sample code below. It offers a list of current processes, from which you dbl-click one to inspect.

Once you choose a process, a snapshot of all Virtual memory allocations is shown in a ListView, along with the size, type, etc. If it’s an image, the filename is shown too.  Hovering over addresses shows the memory contents in a tooltip. Double click to open another window with the entire memory contents. You can read strings in memory in these displays.

One can imagine this being the base of your own custom Task Manager. Perhaps you want to search for all strings in all processes. “Microsoft” occurs quite often!

Imagine taking a memory snapshot of a process, doing something in that process, then taking another snapshot and displaying the difference.

Caveats: you may not have rights to read some processes or some memory. Also, if you build to 32 bit (Project Options->Compile->AdvancedCompileOptions->TargetCPU->AnyCpu) and run on 64 bit, you might have problems.

It can examine both 32 and 64 bit processes.  If you get Access Denied on some processes, you might have better luck running it as Administrator

Start Visual Studio 2008
File->New Project->VB WPF Application.

Open Window1.xaml.vb, replace the contents (about 650 lines) with the sample below.


Read more: Calvin Hsia's WebLog

Posted via email from .NET Info

0 comments: