Do (statically linked) DLLs use a different heap than the main program?

Posted by happy_emi on Stack Overflow See other posts from Stack Overflow or by happy_emi
Published on 2012-05-30T16:11:50Z Indexed on 2012/05/30 16:41 UTC
Read the original article Hit count: 172

Filed under:
|
|
|
|

I'm new to Windows programming and I've just "lost" two hours hunting a bug which everyone seems aware of: you cannot create an object on the heap in a DLL and destroy it in another DLL (or in the main program).

I'm almost sure that on Linux/Unix this is NOT the case (if it is, please say it, but I'm pretty sure I did that thousands of times without problems...).

At this point I have a couple of questions:

1) Do statically linked DLLs use a different heap than the main program?

2) Is the statically linked DLL mapped in the same process space of the main program? (I'm quite sure the answer here is a big YES otherwise it wouldn't make sense passing pointers from a function in the main program to a function in a DLL).

I'm talking about plain/regular DLL, not COM/ATL services

EDIT: By "statically linked" I mean that I don't use LoadLibrary to load the DLL but I link with the stub library

© Stack Overflow or respective owner

Related posts about Windows

Related posts about linux