Try this:
ManagementObjectSearcher search = new ManagementObjectSearcher("root\\CIMV2", "Select TotalVisibleMemorySize, FreePhysicalMemory from Win32_OPeratingSystem");
foreach (ManagementObject x in search.Get())
{
ulong totalMemory = (ulong)x["TotalVisibleMemorySize"];
ulong freeMemory = (ulong)x["FreePhysicalMemory"];
}
freeMemory is returned in KB, and seems about right on my system. It's difficult to be precise, because the system free memory varies all the time as processes allocate and free memory as a part of their normal activity.