谁将堆分配给DLL? [英] Who allocates heap to a DLL?

查看:86
本文介绍了谁将堆分配给DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我使用MS Visual Studio 2005/2008开发了一个DLL,例如1.dll,然后在加载时将此DLL链接到控制台应用程序(例如1.exe)(使用头文件和.lib文件),然后在DLL内部,如果我在运行时分配内存,那么谁将堆(免费存储)分配给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.

据我了解,DLL使用进程的地址空间来存储数据,代码和堆栈。

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

推荐答案

在创建Dll时-始终使用某种语言编写-在使用Visual Studio 2005或2008的情况下使用C ++。

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

在这种情况下,是C ++运行时,负责创建其免费存储并决定如何分配它。

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

具体来说,如果使用Dll运行时选项,则使用单个dll-msvcrtxx。 dll-管理与该DLL链接的所有dll和exe之间共享的单个免费存储。

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.

如果在查询exe时使用静态运行时选项和dll,然后exe和每个dll都会获得内置的libc实例,并具有自己的免费存储管理。

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.

这篇关于谁将堆分配给DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆