开发者

Memory mapped files: how to monitor memory usage

开发者 https://www.devze.com 2023-02-15 04:04 出处:网络
I work on a 32 bit end user application that needs a lot of memory. Up to several gigabytes. I recently switched our internal memory allocation strategy to use memory-mapped-files-without-files inspir

I work on a 32 bit end user application that needs a lot of memory. Up to several gigabytes. I recently switched our internal memory allocation strategy to use memory-mapped-files-without-files inspired by this Raymond Chen article. It works 开发者_开发技巧great.

The only downside is this: If I allocate a gigabyte of memory this way, it does not show up anywhere in the performance counters. Of course, I do know how much is allocated, and how much of it is mapped into my adress space, but I don't know how it's divided over physical memory and the page file. I would like to know, if not for any other reason than logging it for debugging.


The solution was to monitor my application with sysinternals' VMMap. This breaks down an applications memory usage by allocation type (my memory mapped files are called "shared"), as well as by status (in memory or swapped out).

There's even a graphical memory fragmentation map!


Call QueryWorkingSet and count the number of pages that lie within your mapped range to determine how much of your memory is part of the working set. But keep in mind that pages could be excluded from the working set but still be in physical memory somewhere.

0

精彩评论

暂无评论...
验证码 换一张
取 消