views:

197

answers:

3

Two applications share memory by MMF. A create MMF (about 1GB), B open that MMF file by name. When I see Windows Task Manager, A has 1GB memory. But, after several closing and launching B app again, (or after 1 days later? I'm not sure how to reproduce) A's memory in Windows Task Manager is below 1K bytes.

My guess is, maybe because A app doesn't do anything after create MMF, so, Windows thinks MMF is belong to B app. (Just guess).

My OS is Windows 2003 Enterprise x64, SP2.

Is there somebody who knows the reason? Thanks in advance.

A: 

My understanding is that 1GB is reserved in the virtual address space, but memory is only actually allocated for pages that are touched. Memory mapped files are implemented parallel to the Virtual Memory API, and both build upon the NT Virtual Memory Manager. See this article and diagram for an explanation.

Did you fill your entire file with data, or did you just allocate 1GB?

UPDATE:

Which column are you viewing in Task Manager?

The default Memory (Private Working) represents physically allocated memory.

You can add the column Commit Size to see the total amount of virtual address space allocated to the process.

Here is a summary of the various memory statistics you can see in Task Manager and what they mean.

Eric J.
I create MMF for loading some resource.So, I fill that MMF with data.
P-P
+1  A: 

Memory mapped file is still part of your Virtual Address Space, use perfmon to get reliable counters instead of Task Manager, which changes with each release of Windows. The Perfmon counter of Process | Virtual Bytes (total VAS) is the most interesting.

Chris O
A: 

It's because of memory working set minimize.

Thanks for everyone. :)

P-P