0

In task manager now i see that in use 4.7gb of ram out of 6gb.

Im using this class to get my ram:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Management;

namespace ScreenVideoRecorder
{
    class GetMemory
    {
        public static List<UInt32> DisplayTotalRam()
        {
            List<UInt32> uints = new List<UInt32>();
            string Query = "SELECT MaxCapacity FROM Win32_PhysicalMemoryArray";
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(Query);
            foreach (ManagementObject WniPART in searcher.Get())
            {
                UInt32 SizeinKB = Convert.ToUInt32(WniPART.Properties["MaxCapacity"].Value);
                UInt32 SizeinMB = SizeinKB / 1024;
                UInt32 SizeinGB = SizeinMB / 1024;
                //Console.WriteLine("Size in KB: {0}, Size in MB: {1}, Size in GB: {2}", SizeinKB, SizeinMB, SizeinGB);
                uints.Add(SizeinKB);
                uints.Add(SizeinMB);
                uints.Add(SizeinGB);
            }
            return uints;
        }
    }
}

And for the test in Form1 i did :

List<UInt32> uints = GetMemory.DisplayTotalRam();

I see now using a breakpoint in the units List :

index [0] i see: 33554432
index [1] i see: 32768
index [2] i see: 32

In task manager 4.7/6.0 (78%)

So why im getting 32 ? (3.2gb)

joneK
  • 241
  • 1
  • 4
  • 13
  • 2
    It might be (i'm not sure, never used it) because your app is compiled in "32 bits mode". – Deblaton Jean-Philippe Jun 10 '13 at 22:11
  • I would have a look here : http://stackoverflow.com/a/105109/327083 and here : http://stackoverflow.com/a/8463917/327083 – J... Jun 10 '13 at 22:14
  • 1
    Also, it pays to read the documentation (From MSDN) : **MaxCapacity** - *Maximum memory size (in bytes) installable for this particular memory array.* This is the max *installable* capacity - not *installed*. http://msdn.microsoft.com/en-us/library/windows/desktop/aa394348%28v=vs.85%29.aspx – J... Jun 10 '13 at 22:19

1 Answers1

3

On your system, memory-mapped I/O is taking up the last 0.8 GB of 4 GB of address space, which makes it unavailble to address RAM. Therefore, when 4 GB of RAM is loaded in the machine, Windows reports that it has only 3.2 GB installed.

There are other systems where that memory-mapped I/O space is pushed out much higher than 4 GB to get around this. A few years ago I had a Dell laptop with the same issue, so it's not uncommon.

STLDev
  • 5,950
  • 25
  • 36