Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get System Memory in C#.net windows application?

How to get System Memory in C#.net windows application?

Scheduled Pinned Locked Moved C#
csharpperformancetutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Narendra Reddy Vajrala
    wrote on last edited by
    #1

    Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O

    L L 2 Replies Last reply
    0
    • N Narendra Reddy Vajrala

      Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I suppose you could P/Invoke to GlobalMemoryStatus[^], for which you will need a MEMORYSTATUS[^] There could be a better way though..

      1 Reply Last reply
      0
      • N Narendra Reddy Vajrala

        Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, use the Ex versions, otherwise you will be in trouble when more than 2GB is present:

        [DllImport("kernel32.dll")]
        public static extern void GlobalMemoryStatusEx(ref MEMORYSTATUSEX ms);

        public struct MEMORYSTATUSEX {
        ///
        public int Length; // DWORD
        ///
        public int MemoryLoad; // DWORD
        ///
        public long TotalPhys; // DWORDLONG
        ///
        public long AvailPhys; // DWORDLONG
        ///
        public long TotalPageFile; // DWORDLONG
        ///
        public long AvailPageFile; // DWORDLONG
        ///
        public long TotalVirtual; // DWORDLONG
        ///
        public long AvailVirtual; // DWORDLONG
        ///
        public long AvailExtendedVirtual; // DWORDLONG
        }

        :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


        modified on Monday, April 20, 2009 2:29 PM

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups