gpt4 book ai didi

c++ - 安置-新的和第 3 方控制的分配

转载 作者:行者123 更新时间:2023-11-30 02:49:07 27 4
gpt4 key购买 nike

我正在尝试在共享内存段中分配一个第三方类(不是我写的)。

不知道这个类是如何实现的,但它可能包含另一个"new"、“malloc”调用来为其需要分配内存。

这是否意味着这个新内存将不会在共享内存段内分配并且将使用标准堆 - 结果 fork 进程将导致段错误访问此类的函数?

最佳答案

Does it mean that this new memory will not be allocated inside the shared memory segment and will use standard heap - as a result forked processes will cause segmentation fault accessing functions of this class?

没错。如果其他类使用 new 分配它自己的东西,那么这些东西将不会在您的 placement-new 缓冲区中。

关于c++ - 安置-新的和第 3 方控制的分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21537945/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com