Hi.
I have a small question about the heap.
In dos, the heap was the memory area between all defined segments of a program and the beginning (or end, however you wanna see it) of the stack, which is growing from top to bottom:
64 kbyte segment:
------------------------- FFFFh
stack |
heap |
program segments|
------------------------- 0h

But what exactly is a heap in win9x? And why should i use a heap in win9x instead of Globalxxx or Virtualxxx functions? i don't understand the use of a heap in win9x. can someone explain this a little bit?

thanks.
Posted on 2001-12-17 06:51:16 by darester
Hi !

The Heap under WinXX is a memory area for local data and is a part of the process' address-space. So like in DOS you can alloc some memory space there for your local data - One of the differences between the dos-heap and Win9x/WinNt/Win2K/... - heap is that another process normaly can't access this heap.
The reason why the globalxxx and virtualxxx-functions should not be used anymore is that they exists only for Win3.x-compatibilty (and therefore for 16-bit-processes !)


Greetings, CALEB
Posted on 2001-12-17 09:53:23 by Caleb
thanks for your reply!
so - if i understood this correctly - there is actually no heap anymore in win9x in 32bit programs. i mean, if there were no 16bit porgrams, then there were no heap functions when they are only for 16bit programs. so 32bit programs don't have a heap and shouldn't use the heap functions. is this correct?
Posted on 2001-12-17 11:10:10 by darester
In general, a heap is any memory region where you're allowed to allocate and free "loadable/writable" memory in an arbitrary order. (Unlike stack memory which is last-in(allocated)-first-out(freed).)

In Win32, the builtin heap must be managed with the API functions. Win32 complicates things a bit by saying you can have more than one heap per process. In reality, all these little Heaps are part of the one big, builtin heap.

So what is this builtin heap? Take your 4G process address space, then subtract the system region (upper 2G), the lower region (64K in NT/2000/XP, 1M in 9x), the loaded EXE and DLL files, and the reserved stack and data areas (defined in the PE headers). What's left is what's unused when you start the program -- the heap space.
Posted on 2001-12-17 16:27:33 by tank