Я разработал следующий очень простой эксперимент:
main.cpp:
Код: Выделить всё
#include
#include
#include
#include "mylib.h"
int main()
{
MyLib lib;
while (true)
{
lib.printString();
std::this_thread::sleep_for(std::chrono::seconds(5));
}
return 0;
}
Код: Выделить всё
#ifndef MYLIB_H
#define MYLIB_H
class MyLib
{
public:
void printString();
private:
int counter = 0;
};
#endif // MYLIB_H
Код: Выделить всё
#include "mylib.h"
#include
// Define the large string in the implementation file
constexpr const char *largeString =
"This is a very large string that will be used to fill up the .text section "
"of the shared library. It needs to be big enough to be noticeable........................................................ ";
void MyLib::printString()
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78739359/do-processes-share-the-read-only-sections-of-common-dynamically-loaded-libraries[/url]