Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: available memory

Author: Scott Gasch

Date: 15:18:17 10/04/01

Go up one level in this thread


On October 04, 2001 at 08:47:44, JW de Kort wrote:

>Hi friends,
>
>just a simple question. I want my hashtable to be as big as possible but in
>order to decide the size i need to know how much physical memory is still
>available. The problem is however that i do not know which instruction i should
>use to get the size of the available memory. Iám using Visual C++ 4.2. Can
>anybody help me?
>
>thanks!
>
>Jan Willem

If you are only writing for win32 you can use the GlobalMemoryStatus[Ex] call.
It returns a struct with the approx percentage of physical memory in use and the
total size of physical memory on the system.  This is totally non-portable and,
further, the call only works right on win2k and later... and on machines with <=
4Gb of memory.

And, of course, the return struct is a snapshot... its possible that you could
make this call just before some other process allocated a ton of memory and
would then be working with stale information.

While I'm talking about memory management on win32, let me encourage you to have
a look at VirtualLock, VirtualProtect and Get/SetProcessWorkingSetSize.
http://msdn.microsoft.com.

Good luck,
Scott






This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.