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 6176533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:07:05+00:00 2026-05-24T00:07:05+00:00

The description for GlobalMemoryStatusEx() in MSDN says: The information returned by the GlobalMemoryStatusEx function

  • 0

The description for GlobalMemoryStatusEx() in MSDN says:

The information returned by the GlobalMemoryStatusEx function is volatile. There is no guarantee that two sequential calls to this function will return the same information.

One piece of information returned by this function is “Total physical memory in bytes”. (This is different from the amount of FREE physical memory available, there is another member of the MEMORYSTATUSEX structure for that.)

How is it possible for the total physical memory to change every time the program is run? I output the values to the a text file and got these results:

55872198592
55837267904
8589934605
55835301824
55848146880
55849064384
55849129920
55836743616
8589934605
8589934605
8589934605
8589934605
55835105216

I have 4GB of system RAM. Do I need to call another API function if I am on a 64 bit OS?

Here is the code:

#include <Windows.h>
#include <string>
#include <sstream>
#include "Game.h"
#include <fstream>

void Game::CheckMemory(DWORDLONG& a)
{
MEMORYSTATUSEX status;
GlobalMemoryStatusEx(&status);

a = status.ullTotalPhys;

std::stringstream ss;

ss << "Total Physical Memory: " << status.ullTotalPhys << "bytes." << std::endl;

MessageBoxA(NULL, ss.str().c_str(), "Mem Summary", 0);
}

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                PSTR szCmdLine, int iCmdShow)
{
DWORDLONG a;
Game g;
g.CheckMemory(a);

std::fstream fs("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);

fs << a << std::endl;

fs.close();

return 0;
}
  • 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. Editorial Team
    Editorial Team
    2026-05-24T00:07:06+00:00Added an answer on May 24, 2026 at 12:07 am

    You must initialize the dwLength member of MEMORYSTATUSEX before calling the function.

    MEMORYSTATUSEX status;
    status.dwLength = sizeof(status);
    GlobalMemoryStatusEx(&status);
    

    and you should be checking its return value before doing anything with the structure.

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

Sidebar

Related Questions

Description for Assert.Equals() from the MSDN Documentation: Do not use this method. That's it,
DESCRIPTION I have two datasets with information that I need to merge. The only
Description According to the explain command, there is a range that is causing a
The description of System.Collection.Specialized.HybridDictionary is this: Implements IDictionary by using a System.Collections.Specialized.ListDictionary while the
The description of CoLoadLibrary() says it does pretty much the same as LoadLibraryEx() -
After reading this description of late static binding (LSB) I see pretty clearly what
I found a good description on wikipedia with a few reference links, but there
Description: I have a column(EmailsAdress) on a table(BusinessUsers) on my databases that stores email
Description: An error occurred during the parsing of a resource required to service this
I guess my description is not clear enough. So I'll try again: Imagine there

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.