[Insight-developers] itksys:SystemInformation returns invalid memory information under windows

Bill Hoffman bill.hoffman at kitware.com
Wed Nov 18 09:53:14 EST 2009


M.Staring at lumc.nl wrote:
> Hi all,
> 
> I am using 
> 
>   itksys::SystemInformation info;
>   info.RunMemoryCheck();
> 
> to obtain information about the total physical memory that is available
> on a windows system.
> 
> However, the function returns incorrect results. When digging into the
> code I saw that itksys internally uses the windows function
> GlobalMemoryStatusEx for my particular system (windows XP, 64 bit, 4 GB
> of memory, Visual Studio 2008). As an alternative I used
> GlobalMemoryStatus instead of GlobalMemoryStatusEx, which does seem to
> work. These are the results I get in MB:
> 
> Debug mode:
>   TotalPhysicalMemory ITK:3276
>   GlobalMemoryStatusEx:3276
>   GlobalMemoryStatus:4079
> 
> Release mode:
>   TotalPhysicalMemory ITK:1024
>   GlobalMemoryStatusEx:0
>   GlobalMemoryStatus:4079
> 
> Where the first line is the itksys implementation, the second a direct
> windows call to GlobalMemoryStatusEx and the last a direct call to
> GlobalMemoryStatus. Note the different results in debug and release mode
> for itksys and GlobalMemoryStatusEx. GlobalMemoryStatus does give me the
> correct results. I have attached the code to reproduce these figures.
> 
> Is there a reason why GlobalMemoryStatusEx is used for MSC_VER > 1300,
> see line 2273 and following of Utilities/kwsys/SystemInformation.cxx ?
> Is this a bug?
> 
> Thanks for your advice, regards,
> 

The MSDN docs seems to say the opposite of what you are seeing...

http://msdn.microsoft.com/en-us/library/aa366586%28VS.85%29.aspx

What compiler are you using?

-Bill

-- 
Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
bill.hoffman at kitware.com
http://www.kitware.com
518 881-4905 (Direct)
518 371-3971 x105
Fax (518) 371-4573


More information about the Insight-developers mailing list