[comp.windows.ms.programmer] Huge global memory allocations

ddoherty@ics.uci.edu (Donald Doherty) (01/30/91)

	I need to allocate at least three segments (~180k) of type
int to global memory.  This I have done using

	int huge *lpGlobalMemory;
	.
	hGlobalMemory = GlobalAlloc (GMEM_MOVEABLE, ~180k);

as suggested in Petzold.
	This works fine only as long as I use 64k or less of the space!
If I enter > 64k of data the system crashes with a runtime error.
Has anyone had any similar experiences?  Any suggestions that might help
me through this painfull adolescence in my Windows memory management
experience?

Thank-you!

Don D.
ddoherty@ICS.uci.edu

burgoyne@eng.umd.edu (John R. Burgoyne) (01/30/91)

In article <27A5DC96.4539@ics.uci.edu> ddoherty@ics.uci.edu (Donald Doherty) writes:
>
>	I need to allocate at least three segments (~180k) of type
>int to global memory.  This I have done using
>
>	int huge *lpGlobalMemory;
>	.
>	hGlobalMemory = GlobalAlloc (GMEM_MOVEABLE, ~180k);
>
>as suggested in Petzold.
>	This works fine only as long as I use 64k or less of the space!
>If I enter > 64k of data the system crashes with a runtime error.
>Has anyone had any similar experiences?  Any suggestions that might help
>me through this painfull adolescence in my Windows memory management
>experience?
>
>Thank-you!
>

You have to lock your memory, as in the following example:

kx =(float huge *) GlobalLock(GlobalAlloc(GMEM_FIXED, sizecount*sizeof(float) )
ky =(float huge *) GlobalLock(GlobalAlloc(GMEM_FIXED, sizecount*sizeof(float) )
kz =(float huge *) GlobalLock(GlobalAlloc(GMEM_FIXED, sizecount*sizeof(float) )

Hope it helps.

Robert