Check memory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Firecore
    New Member
    • Jul 2007
    • 114

    Check memory

    Is there is function in C that allows you to see how much memory the pc has left at that particular time?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    On what OS.

    On Windows then the answer is not really. You can find out how much memory is in use but in these days of expanding swap files providing extra virtual memory as required the question "how much memory is left" does not really make sense because the answer is "how much would you like there to be?".

    Comment

    • Firecore
      New Member
      • Jul 2007
      • 114

      #3
      Originally posted by Banfa
      On what OS.

      On Windows then the answer is not really. You can find out how much memory is in use but in these days of expanding swap files providing extra virtual memory as required the question "how much memory is left" does not really make sense because the answer is "how much would you like there to be?".
      I mean how much physical memory is left in XP. So you are saying there is no definite way to find this out?

      Because I thought it would be a cool addtition for my program to have a thing which tells you how much RAM you have left in the installation. I have figured out the HDD bit.

      Comment

      • mostafa110
        New Member
        • Oct 2007
        • 6

        #4
        Hello
        The below code used in MFC.
        You must type below code:
        __int64 Memstatus()
        {
        MEMORYSTATUS mem;
        GetMemoryStatus (&mem);
        return mem.dwAvailPhys ;
        }
        Other variables are :
        DWORD dwLength;
        DWORD dwMemoryLoad;
        SIZE_T dwTotalPhys; //Total physical memory installed on computer
        SIZE_T dwAvailPhys;
        SIZE_T dwTotalPageFile ;
        SIZE_T dwAvailPageFile ;
        SIZE_T dwTotalVirtual; //total virtual memory
        SIZE_T dwAvailVirtual;

        Note: if Ram bigger than 4 GB MEMORYSTATUS may not response,thus you must use MEMORYSTATUSEX and GetMemoryStatus Ex.
        Best regards,

        Comment

        • Firecore
          New Member
          • Jul 2007
          • 114

          #5
          I see.
          Ill give that a go.
          Thanks

          Comment

          Working...