Computer Chess Club Archives


Search

Terms

Messages

Subject: OT: How to alloc large memory size (in Windows)?

Author: Pham Hong Nguyen

Date: 15:22:11 01/31/04


Hi all,

I have been working on generating endgame databases and want to alloc some large
blocks of memory (without exceeding 2 Gb - I know 2 Gb is the limitation for a
Windows program).

The program for testing is quite simple as the following (written in VC++):

int main()
{
// Few init here
int tbsize = 800000000; // 800 Mb
HGLOBAL hg1 = GlobalAlloc(GHND, tbsize); ASSERT(hg1);
HGLOBAL hg2 = GlobalAlloc(GHND, tbsize); ASSERT(hg2);
}


It work well if I set tbsize <= 660 000 000 (660 Mb, total size is 1.3 Gb), but
the second assert fails if tbsize from 670 Mb. GetLastError() says: "Not enough
storage is available to process this command". However, I think my machine has
enough memory (Win2k, 2 Gb RAM, 20 available HDD, runing only this test
program).

I did some other tries:
- Adding 512 Mb RAM (so my machine now has 2.5 Gb RAM)
- Using VirtualAlloc instead of GlobalAlloc

Unfortunately, the situation is still the same: 660 Mb ok, 670 Mb fails (not
gain any more) and same message of GetLastErr().

So, do you know why and how to solve this problem?
Any help is highly appreciated.

+Pham





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.