View Full Version : Memory alocation in windows

June 27th, 2007, 01:59
Hi all
In my small program,I forced to write several threads(5 of them) and heavily process some data and APIs in it.
One of these important APIs is "GlobalAlloc" and "GlobalFree",it means that I forced to allocated some memory at start of a loop in my thread using GlobalAlloc(with GPTR flag) and free it using GlobalFree at the and of loop,and this happens for all threads.

Here is my question:
Is there any guarantee that my allocated memory in a thread has no overlapping with allocated memory in other threads?


June 27th, 2007, 03:10
GlobalAlloc calls RtlLockHeap which in turn calls RtlEnterCriticalSection*. I suppose this is similar to the wine source**. So I think GlobalAlloc is thread safe. Just like a single thread there is no chance to get the same memory twice.