mono/mono — pull request #1414 by exony-craigminihan (2014-11-19 14:04:30+00:00)
Title: Process.PagedMemorySize64 now returns value from /proc/PID/status

Kernels after 2.12 report VmSwap status in /proc (see https://www.kernel.org/doc/Documentation/filesystems/proc.txt). Mono exposes some memory info via System.Diagnostics.Process but not swap/paging info. Knowing page/swap state is critcal for my app since it maintains large in-memory caches.

Simple test code:
```
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

public static class Program
{
public static void Main(string[] args)
{
var process = System.Diagnostics.Process.GetCurrentProcess();

long physicalMemorySize = -1;
var pc = new PerformanceCounter("Mono Memory", "Total Physical Memory");
if (pc.RawValue > 0)
{
physicalMemorySize = pc.RawValue;
}

int blocks = (int)(physicalMemorySize / 1024);
int blockSize = blocks;
var emptyData = new byte[blockSize];
for (int i = 0; i < 1024; i++)
{
var data = Marshal.AllocHGlobal(blockSize);
Marshal.Copy(emptyData, 0, data, blockSize);
}

var msg = string.Format(
"Process: id={0}\n" +
"CPU: user={1:N1}s, total={2:N1}s\n" +
"Threads: count={3}\n" +
"Memory: physical={4:N}MB, working={5:N0}MB, virtual={6:N0}MB, private={7:N0}MB, paged={8:N0}MB\n" +
"GC: totalMemory={9:N0}MB, count0={10}, count1={11}",
process.Id,
process.UserProcessorTime.TotalSeconds, process.TotalProcessorTime.TotalSeconds,
process.Threads.Count,
physicalMemorySize >> 20, process.WorkingSet64 >> 20, process.VirtualMemorySize64 >> 20, process.PrivateMemorySize64 >> 20, process.PagedMemorySize64 >> 20,
GC.GetTotalMemory(false) >> 20, GC.CollectionCount(0), GC.CollectionCount(1));

Console.WriteLine(msg);

Console.ReadLine();
}
}
```