AMIT SHELKE
AMIT SHELKE

Reputation: 533

Total Page File size of my computer using C#

I am trying to read the Total Page file size for all drives. On my computer it show around 8375 MB. [When I see from control panel]

But when I try to get same value from C# code, it is different. I have used GlobalMemoryStatusEx() function of kernel32.dll to read the same value (i.e. dwTotalPageFile) from my code. It shows some 17247666176 byte value which is equal to 16448.65 MB

[return: MarshalAs(UnmanagedType.Bool)]

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool **GlobalMemoryStatusEx**([In, Out] MEMORYSTATUSEX lpBuffer);

[OS : Windows 7 x64]

Please can anyone help me out!

Upvotes: 2

Views: 1728

Answers (1)

user2176240
user2176240

Reputation:

PagedSystemMemorySize64 is the total number bytes of operating system kernel memory in the paged memory pool attributed to the process. It corresponds with the "Paged Pool" column in Taskmgr.exe.

PagedMemorySize64 is the total number of bytes of user mode virtual memory allocated for the process. It corresponds with the "Commit Size" column in Taskmgr.exe.

Note that processes share memory in these sections, the sum of the allocations of all processes is much greater than the actual amount of memory used. You furthermore cannot reasonably calculate the amount of "unused" space in the paging file, Windows dynamically expands and shrinks it based on what running processes require.

Upvotes: 2

Related Questions