C++: Virtual Table and Shared Memory

See at:补充栏3: C++对象和共享内存 (叙述内容和Link1的内容基本一致)

《C++网络编程 卷1:运用ACE和模式消除复杂性》 《C++ Network Programming Volume 1 Mastering Complexity with ACE and Patterns》 -Douglas C.Schmidt, Stephen D. Huston -叶斌译

Link1:

Is it possible to store polymorphic class in shared memory? -> No

http://stackoverflow.com/questions/12969391/is-it-possible-to-store-polymorphic-class-in-shared-memory

引自

http://www.boost.org/doc/libs/1_51_0/doc/html/interprocess/sharedmemorybetweenprocesses.html#interprocess.sharedmemorybetweenprocesses.mapped_region_object_limitations

Virtuality forbidden

The virtual table pointer and the virtual table are in the address space of the process that constructs the object, so if we place a class with a virtual function or virtual base class, the virtual pointer placed in shared memory will be invalid for other processes and they will crash.

This problem is very difficult to solve, since each process needs a different virtual table pointer and the object that contains that pointer is shared across many processes. Even if we map the mapped region in the same address in every process, the virtual table can be in a different address in every process. To enable virtual functions for objects shared between processes, deep compiler changes are needed and virtual functions would suffer a performance hit. That‘s why Boost.Interprocess does not have any plan to support virtual function and virtual inheritance in mapped regions shared between processes.

..

时间: 2024-10-10 02:18:26

C++: Virtual Table and Shared Memory的相关文章

Multiple address space mapping technique for shared memory wherein a processor operates a fault handling routine upon a translator miss

Virtual addresses from multiple address spaces are translated to real addresses in main memory by generating for each virtual address an address space identifier (AID) identifying its address space. Then, the virtual address and its AID are used to o

Android系统匿名共享内存(Anonymous Shared Memory)C++调用接口分析

一.Ashmem驱动程序 ~/Android/kernel/goldfish ----include ----linux ----ashmem.h ----mm ----ashmem.c 驱动程序详解请看<Android系统源代码情景分析>,作者罗升阳. 二.运行时库cutils的匿名共享内存访问接口 ~/Android/system/core ----libcutils ----ashmem-dev.c 详解请看<Android系统源代码情景分析>,作者罗升阳. 三.Memory

ORA-04031:unable to allocate 4120 bytes of shared memory ‘obj stat mem’故障解决

客户报表库,HP-ux B11.31 IA64 FOR Oracle 10.2.0.5.0 RAC系统短信过滤alert日志告警 ORA-00604: error occurred at recursive SQL level 1 ORA-04031:unable to allocate 4120 bytes of shared memory ("shared pool","select f.file#, f.block#, f....","Typeche

Shared Memory共享内存----kithara RTS

翻译注:共享内存是程序之间进行数据交互的最基本的方式,而由于windows和kithara rts本身为两个独立的系统,为了能够使两个不同系统之上的程序进行通信,那么就必须开辟一块内存区域用于数据共享.本文是对kithara rts官方原文进行的翻译,加入了本人的一些使用经验. Shared Memory(共享内存) What you need to know about Shared Memory(共享内存基本知识) In 32-bit and64-bit Windows operating

ORA-04031: Unable To Allocate 32 Bytes Of Shared Memory

记录一次生产库遇到的4031错误,后来通过调整sga大小将问题解决了 报错信息: ORA-04031: 无法分配 32 字节的共享内存 ("shared pool","select user#,password,datats...","SQLA","tmp")Incident details in: /u01/app/oracle/diag/rdbms/twprod/xxxxx/incident/incdir_237848/x

ALERT: Setting RemoveIPC=yes on Redhat 7.2 Crashes ASM and Database Instances as Well as Any Application That Uses a Shared Memory Segment (SHM) or Semaphores (SEM) (Doc ID 2081410.1)

数据库实例自动crash并报ORA-27157.ORA-27300等错误 一.文档: ALERT: Setting RemoveIPC=yes on Redhat 7.2 Crashes ASM and Database Instances as Well as Any Application That Uses a Shared Memory Segment (SHM) or Semaphores (SEM) (Doc ID 2081410.1) In this Document Descri

Insufficient space for shared memory file

linux下应用无故反应异常,登陆服务器查看发现: -bash-4.1$ jps Java HotSpot(TM) 64-Bit Server VM warning: Insufficient space for shared memory file:    /tmp/hsperfdata_kf01/4830 Try using the -Djava.io.tmpdir= option to select an alternate temp location. 4830 Jps -bash-4.

nginx: [emerg] the size 10485760 of shared memory zone "cache_one" conflicts with already declared size 0

注意配置段中的区域包含关系.proxycachepatch 要在proxy_cache前已经定义. what seems to be the problem? [emerg]: the size 52428800 of shared memory zone "media" conflicts with already declared size 0 in /etc/nginx/conf.d/cache.conf:5 configuration file /etc/nginx/nginx

ORA-27101: shared memory realm does not exist

Oracle Error Tips by Burleson Consulting Oracle docs note this about ORA-27101: Cause: Unable to locate shared memory realm Action: Verify that the realm is accessible The solution in Windows may be to start the Windows services. MOSC offers valuable