GlobalMemoryStatusEx - Bug in source

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • GlobalMemoryStatusEx - Bug in source

      I searched the forum and didn't find any references to this so I figured I'd post what I've found. While trying to get the EditorApp to work (I'm still trying) I was stepping through the source and found a problem in the CheckMemory function in the initialization.cpp file under the GameCode3 project. I kept getting a GameCodeError every time the code called GlobalMemoryEx. The problem is that the MEMORYSTATUSEX structure length is not being set prior to the call. Once I added code to initialize the structure the call worked without a problem. Now if I can just get the #$%# EditorApp to work! 8| The modified source code follows:

      void CheckMemory(const DWORDLONG physicalRAMNeeded, const DWORDLONG virtualRAMNeeded)
      {
      MEMORYSTATUSEX status;
      status.dwLength = sizeof (status); //<== This line was added
      GlobalMemoryStatusEx(&status);
      if (status.ullTotalPhys < (physicalRAMNeeded))
      {
      // you don't have enough physical memory. Tell the player to go get a real
      // computer and give this one to his mother.
      throw GameCodeError(GCERR_INIT_NOT_ENOUGH_PHYS_RAM);
      }
      .
      .
      .

      In the version of the code I am running the CheckMemory method starts at line 74

      The post was edited 1 time, last by KeithH ().

    • RE: GlobalMemoryStatusEx - Bug in source

      Whoops - that is a classic Win32 error.

      Nice catch...
      Mr.Mike
      Author, Programmer, Brewer, Patriot