Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 41863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:14:52+00:00 2026-05-10T15:14:52+00:00

Using C#, I want to get the total amount of RAM that my computer

  • 0

Using C#, I want to get the total amount of RAM that my computer has. With the PerformanceCounter I can get the amount of Available ram, by setting:

counter.CategoryName = 'Memory'; counter.Countername = 'Available MBytes'; 

But I can’t seem to find a way to get the total amount of memory. How would I go about doing this?

Update:

MagicKat: I saw that when I was searching, but it doesn’t work – ‘Are you missing an assembly or reference?’. I’ve looked to add that to the References, but I don’t see it there.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:14:53+00:00Added an answer on May 10, 2026 at 3:14 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SPList I want to get all the webpart urls that associated with the
Using Doctrine 2 I want to get some users that are contacts of another
I want to get the class name using jQuery And if it has an
I want to get total count of sparql query results. I am using jena
Using Access 2003 I want to get a table value from the two databases
Using VB.Net I want to get a all datagrid cell values, then insert into
I want to get data using CURL but I have a problem. When I
I want to get the video stream from my webcam using python and OpenCV,
I want to get list of columns of a table using GetSchema method in
I want to get the value of div using webdriver and not Selenium For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.