共享库的内存空间 [英] Shared libraries memory space

查看:92
本文介绍了共享库的内存空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++共享库是否有自己的内存空间?还是共享呼叫者进程的那个?

Does a C++ shared library have its own memory space? Or does it share the caller process' one?

我有一个共享库,其中包含一些类和包装函数. 该包装函数之一是:

I have a shared library which contains some classes and wrapper functions. One of this wrapper function is kinda:

libXXX_construct()初始化一个对象并返回指向该对象的指针.

libXXX_construct() which initializes an object and returns the pointer to the said object.

一旦在调用程序中使用libXXX_construct()放置了对象,它是在调用程序"存储空间中还是在库的存储空间中?

Once I use libXXX_construct() in a caller program where is the object placed?Is it in the "caller" memory space or is it in the library's memory space?

推荐答案

共享库的链接实例共享直接或间接链接到的可执行文件实例的内存空间.对于Windows和类似UN * X的操作系统都是如此.请注意,这意味着共享库中的静态变量不是进程间通信的一种方式(很多人认为).

A linked instance of the shared library shares the memory space of the instance of the executable that linked to it, directly or indirectly. This is true for both Windows and the UN*X-like operating systems. Note that this means that static variables in shared libraries are not a way of inter-process communication (something a lot of people thinks).

这篇关于共享库的内存空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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