On 32-bit Unix operating systems, if the physical memory is >= 4GB, STAF shows 0 for the STAF/Config/Mem/Physical variables instead of the correct physical memory.
This is because in the STAFUtilGetConfigInfo method in stafif/unix/STAFUtil.cpp, we're using an unsigned int as the type for the memory variable which on 32-bit machines has a maximum size of 4,294,967,295 (4GB - 1).
So, on our new AIX 6.1 machine that has 8,589,934,592 bytes of memory, when using the 32-bit kernel, the STAF variables for total memory are all showing 0:
STAF/Config/Mem/Physical/Bytes : 0
STAF/Config/Mem/Physical/KB : 0
STAF/Config/Mem/Physical/MB : 0
when these STAF variables should be showing:
STAF/Config/Mem/Physical/Bytes : 8589934592
STAF/Config/Mem/Physical/KB : 8388608
STAF/Config/Mem/Physical/MB : 8192
The same problem exists on Windows in the STAFUtilGetConfigInfo method in stafif/win32/STAFUtil.cpp, but because we're using an older version of the Windows Visual Studio C/C++ compiler, GlobalMemoryStatusEx is not available, so we have to use GlobalMemoryStatus which is always available. but returns wrong results for physical memory > 4GB. We already have Bug #1780505 "Physical memory reported for Windows is incorrect if >= 2GB" open for that problem. But we should go ahead and change it to use the STAFUInt_t type instead of unsigned long.
We should be able to fix this problem on Unix by using the STAFUInt_t type (or double type) instead of using an unsigned int for the memory variables.
Index: stafif/STAFUtil.h
RCS file: /cvsroot/staf/src/staf/stafif/STAFUtil.h,v
retrieving revision 1.16
diff -r1.16 STAFUtil.h
34c34
< unsigned long physicalMemory;
---
> STAFUInt64_t physicalMemory;
Index: stafif/unix/STAFUtil.cpp
===================================================================
RCS file: /cvsroot/staf/src/staf/stafif/unix/STAFUtil.cpp,v
retrieving revision 1.27
diff -r1.27 STAFUtil.cpp
114,115c114,115
< static unsigned long physicalMemory = 0;
< static unsigned long numProcessors = 0;
---
> static STAFUInt64_t physicalMemory = 0;
> static unsigned int numProcessors = 0;
192c192
< unsigned long numPages = sysconf(_SC_PHYS_PAGES);
---
> STAFUInt64_t numPages = sysconf(_SC_PHYS_PAGES);
217c217
< unsigned long numPages = sysconf(_SC_PHYS_PAGES);
---
> STAFUInt64_t numPages = sysconf(_SC_PHYS_PAGES);
232c232
< unsigned long numPages = ps.physical_memory;
---
> STAFUInt64_t numPages = ps.physical_memory;
247c247
< unsigned long totalMem;
---
> STAFUInt64_t totalMem;