Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measuring memory use of device drivers in Windows

How can I determine how much memory each device driver is consuming? I'm assuming this can be done with some Win32 or .NET API, but I just haven't been able to determine which.

like image 329
Justin R. Avatar asked Dec 27 '08 23:12

Justin R.


People also ask

How do I monitor memory usage on Windows?

Press Ctrl + Shift + Esc to launch Task Manager. Or, right-click the Taskbar and select Task Manager. Select the Performance tab and click Memory in the left panel. The Memory window lets you see your current RAM usage, check RAM speed, and view other memory hardware specifications.

How do I check my memory usage with Performance Monitor?

Method 2 - Using Performance MonitorClick on Performance Monitor. Click on Green colored "Plus" Symbol to open add counters Window. To select Memory, search the list of counters and select Memory, click on Add button and then OK button. When the graph appears on the screen, the graph will indicate memory usage.

How do I monitor my virtual memory usage?

To start Performance Monitor, click Start, click Control Panel, click Administrative Tools, and then double-click Performance Monitor. Here is a summary of some important counters and what they tell you: Memory, Committed Bytes: This counter is a measure of the demand for virtual memory.

How do I detect a memory leak in running process in Windows?

Check RAM With Windows' Memory Diagnostics Tool Press Windows key+R, enter "mdsched.exe," then select OK. Select Restart now and check for problems (recommended). The test will begin and may take several hours to complete.


1 Answers

Windows tracks device driver memory usage with pool tags. If you know what pool tags the driver in question passes to ExAllocatePoolWithTag, then you can track its memory usage using tools such as poolmon (from the Windows Driver Kit), PoolTag (from OSR), or WinDbg (or KD) (from the Debugging Tools for Windows).

Note that device drivers may call kernel APIs that indirectly allocate memory. For example, calling IoAllocateMdl will cause the Windows I/O manager to allocate memory for a memory descriptor list, using a different pool tag that is assigned by the Windows I/O manager. Due to this, allocations performed on behalf of multiple device drivers may all use the same pool tag.

If you're trying to determine which driver is leaking memory, use poolmon/PoolTag/WinDbg/KD identify the pool tag(s) that are being leaked. Then attach a kernel debugger (WinDbg or KD) to the system and set the variable nt!poolhittag to the leaky pool tag. The next time ExAllocatePoolWithTag is called to allocate memory with that pool tag, the system will break into the kernel debugger, and then you can look at the call stack to figure out which driver is performing the allocation. This process is described in more detail in Using the Kernel Debugger to Find a Kernel-Mode Memory Leak.

like image 198
bk1e Avatar answered Nov 15 '22 23:11

bk1e