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 -叶斌译
关于这个问题的一个扩展: p49, class ACE_IPC_SAP的constructor为protected, 这样可以防止其被直接实例化,同时避免了虚指针。
关于这个问题的另一个扩展: p106, 在多线程情况下,可以使用含有虚表的C++对象,利用进程局部内存的公用数据结构。
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.
..
C++: Virtual Table and Shared Memory的更多相关文章
- ORA-27125: unable to create shared memory segment的解决方法(转)
ORA-27125: unable to create shared memory segment的解决方法(转) # Kernel sysctl configuration file for Red ...
- 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 ge ...
- Android系统匿名共享内存(Anonymous Shared Memory)C++调用接口分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6939890 在Android系统中,针对移动设 ...
- 参数SID写错,ERROR OGG-00664 ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist
添加进程,启动进程报错 1.0添加进程 GGSCI (t2) > add ext exta,tranlog,begin now EXTRACT added. --添加exta(ext标准命名规则 ...
- ORA-04031: Unable To Allocate 32 Bytes Of Shared Memory
记录一次生产库遇到的4031错误,后来通过调整sga大小将问题解决了 报错信息: ORA-04031: 无法分配 32 字节的共享内存 ("shared pool","s ...
- RAC数据库的ORA-27123: Unable To Attach To Shared Memory Segment Linux-x86_64 Error: 22: Invalid argument
RAC数据库的 ORA-27123: Unable To Attach To Shared Memory Segment Linux-x86_64 Error: 22: Invalid argumen ...
- ORA-27101: shared memory realm does not exist
Oracle Error Tips by Burleson Consulting Oracle docs note this about ORA-27101: ORA-27101: shared me ...
- shared memory realm does not exist
有天启动ORACLE,碰到如下问题 提示ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist 解决 ...
- Oracle重启 error: ora-01034:oracle not available ora-27101:shared memory realm does not exist
error: ora-01034:oracle not available ora-27101:shared memory realm does not exist 苦咖啡 他的博客中一篇文章完美的解 ...
随机推荐
- bind绑定参数
const curry = (fn) => (...args)=>fn.bind(null,...args); const split = curry((splitOn, str) =&g ...
- 检查日期是否为节假日api
http://www.easybots.cn/api/holiday.php?d=20160104 返回值: 工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2: 检查一个日期是否 ...
- 我的C语言进化史
Hello, world! 这三年就看看我的C语言还有JAVAscript进化史吧.更厉害的sunmarvell,我等你
- BZOJ2802——[Poi2012]Warehouse Store
1.题目巨短,自己看看吧 2.分析:这道题,想了半天dp还是想不到,最后看题解发现是个贪心的思想,我们维护一个堆,如果这个人不能加入就把他和堆上最大的进行比较,然后搞搞就行了 #include < ...
- Integer与int的区别(包装类和基本数据类型的区别)
1. 默认值 int默认值为0,Integer的默认值为null.推论:Integer既可以表示null又可以表示0 2. 包装类中提供了该类型相关的很多算法操作方法 如把十进制装换为2进制(toBi ...
- CSS & JS 制作滚动幻灯片
==================纯CSS方式==================== <!DOCTYPE html> <html> <head> <met ...
- DataScientist————汇总篇
为了方便阅读查找.把写的其他关于机器学习的博客汇总在这里. ---------------------------------------------------------------------- ...
- js抛物线动画——加入购物车动效
参考文章:http://www.zhangxinxu.com/wordpress/2013/12/javascript-js-元素-抛物线-运动-动画/ parapola.js /*! * by zh ...
- WebView随学笔记
对于WebView而言我们需要掌握的内容是: /** 学习目标:webView * 1).将WebView加入到应用中 * 2).使用WebView加载页面 * 3).获取网络访问 * 4).在Web ...
- CornerStone的使用
俗话说:"工欲善其事必先利其器": 对于我们程序员来说,不管你是大神,还是小鱼小虾,进入公司之后,都用过源码管理工具,不然你就不是一个合格的程序员,现在各个公司用于源码管理工具通常 ...