How to Check the Amount of Ram

How to check the amount of RAM

Given the warnings concerning platform-dependency discussed in the earlier comment, you could for example parse /proc/meminfo on Linux:

$ grep MemFree /proc/meminfo 
MemFree: 573660 kB
$ awk '/MemFree/ {print $2}' /proc/meminfo
565464

You could try the second approach via system(..., intern=TRUE), or even via a pipe connection.

Edit some 5+ years later: In R, and just following what the previous paragraph hinted at:

R> memfree <- as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo", 
+ intern=TRUE))
R> memfree
[1] 3342480
R>

How do you get total amount of RAM the computer has?

The Windows API function GlobalMemoryStatusEx can be called with p/invoke:

  [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
private class MEMORYSTATUSEX
{
public uint dwLength;
public uint dwMemoryLoad;
public ulong ullTotalPhys;
public ulong ullAvailPhys;
public ulong ullTotalPageFile;
public ulong ullAvailPageFile;
public ulong ullTotalVirtual;
public ulong ullAvailVirtual;
public ulong ullAvailExtendedVirtual;
public MEMORYSTATUSEX()
{
this.dwLength = (uint)Marshal.SizeOf(typeof(NativeMethods.MEMORYSTATUSEX));
}
}

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

Then use like:

ulong installedMemory;
MEMORYSTATUSEX memStatus = new MEMORYSTATUSEX();
if( GlobalMemoryStatusEx( memStatus))
{
installedMemory = memStatus.ullTotalPhys;
}

Or you can use WMI (managed but slower) to query TotalPhysicalMemory in the Win32_ComputerSystem class.

How to programmatically check the amount of RAM allocated to a JVM?

long maxMemory = Runtime.getRuntime().maxMemory();

That is the max amount of memory a JVM can allocate, measured in bytes.

See the following link to the details of that method:
https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#maxMemory()

How much RAM Does My Program Use? Memory Profiling Report Visual Studio

RAM only contributes as a random access. Computing power is dictated by processing speed/power, therefore, if a heavily fluctuating RAM usage is noticeable, upgrading the RAM itself is not ideal. From what I can tell, it appears that the program requires at least 2gb of RAM to run smoothly and not affect other programs running simultaneously on the same processor.

Another method is to calculate an "average" RAM usage during peak processing (ie. while the program is running during full use). Record the RAM consumption at 2 minute intervals for 20 minutes and divide by 10 to get the average "recommended" RAM.

But, like I said, RAM is only part of the power.

How to determine the RAM Size of my MongoDB Server

There is a tool in the later versions of MongoDB to help with finding out how big your working set is, it is still quite experimental but it should work: http://docs.mongodb.org/manual/reference/command/serverStatus/#serverStatus.workingSet

The best way to use this is simply to make a automated test script which will use your application and in the meantime print out serverStatus and archive the value of the working set document. You can graph it, etc etc and come to a reasonable conclusion of what your RAM needs to be.

Is there any way to check which kind of RAM my computer uses without opening it up?

CPU-Z can tell you. On the SPD tab you can view the DIMM specific information

Check RAM in WIX Installer

Windows Installer sets the system RAM amount in PhysicalMemory property. Usually this property is used as a launch condition which stops the installation and shows a message to the user.

Launch conditions do not allow the user to continue. So if this is not an option, a solution is to use a custom action. Your custom action can check PhysicalMemory and show a custom message box if it's not enough. Based on the user answer, the custom action can then return 0 to continue or 1602 to stop.

Here is a sample condition:

PhysicalMemory >= 1024


Related Topics



Leave a reply



Submit