Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who allocates heap to a DLL? [closed]

Tags:

windows

dll

Suppose I develop a DLL, say 1.dll using MS visual studio 2005/2008, then I link this DLL to a console application, say 1.exe, at load time (using header file and .lib file) then When inside DLL, if I am allocating memory at run time, then who allocates heap (free store) to the DLL.

As I understand that DLL uses process's address space for data, code and stack.

like image 316
Vikas Avatar asked Feb 25 '23 07:02

Vikas


1 Answers

When you make a Dll - you always write it in some Language - in your case C++ using Visual Studio 2005 or 2008.

In which case it is the C++ runtime that is responsible for creating its freestore and deciding how to allocate it.

Specifically, if you use the Dll runtime option, then a single dll - msvcrtxx.dll - manages a single freestore that is shared between all dll's, and the exe, that are linked against that dll.

If you use the static runtime option when beuiding your exe and dlls, then the exe and each dll gets its own instance of libc built in, with its own freestore management.

like image 179
Chris Becke Avatar answered Mar 07 '23 02:03

Chris Becke