[comp.windows.ms.programmer] Big allocations bite the big one?

martinr@ima.isc.com (Martin Romano) (03/19/91)

Is there a limit on the size of a memory block allocated by GlobalAlloc()
*other* than:

	1) 1MB in standard mode
	2) 64MB in 386 enhanced mode
	3) available virtual memory

When I attempt to allocate an 18MB block*, GlobalAlloc() returns a non-zero
handle, but appears to allocate a block slightly smaller than 16MB.

For example:

	HANDLE     hBig = GlobalAlloc(GMEM_MOVEABLE, EighteenMegs);
	char _huge *hpBig = (char _huge *)GlobalLock(hBig);
	...
	dwSize = GlobalSize(hBig); /* dwSize < 16MB !!! */;
	for (i = 0; i < EighteenMegs; i++) 
		*hpBig++ = 'X'; /* Dies around 16MB past start of block. */

My apologies if this is a well-known/much-discussed problem.

* My machine is a Compaq 386/25 with 8MB+640KB memory, ~31MB swap file,
  with Windows running in enhanced mode.
-- 
Martin Romano  Interactive Systems, Cambridge MA  (617)661-7474 x209
{encore, harvard, spdcc, think}!ima!martinr  martinr@ima.ima.isc.com