eXtremeDB 共享内存使用时的注意事项

When using the eXtremeDB Direct Pointer Arithmetic library (DP) it is
necessary to map the shared memory segment to the same virtual memory address
in every process because in the DP implementation eXtremeDB uses actual
memory addresses (i.e. it performs pointer arithmetic) to calculate the locations of
objects in an eXtremeDB database. The pointers must be the same in every
running instance of an eXtremeDB -based application, or pointer arithmetic just
doesn’t work. Setting the dev.named.hint parameter to zero causes eXtremeDB
to determine the actual shared memory segment address. But this could fail when
called from a second process attempting to open the shared database. In this case
it is the applications responsibility to provide a valid “hint” address.
There are several ways to determine where the runtime should map the shared
memory database. Developers can use a utility provided by the operating system
to gather memory usage information (the process memory map). These utilities
will usually display the code, data and stack memory usage of each process
running on the system and the libraries it is using. It is necessary to examine the
output and pick an address outside any address space.
In any event, the memory address is an address in each process’s virtual memory.
An address should be chosen that is sufficiently far away from the data, stack and
heap segment of every process that will share the database. (Hence the default of
0x20000000 for MAP_ADDRESS; it is assumed unlikely, but not guaranteed, that
any single process will have data, stack and heap that stretch out to 0x20000000
bytes.)
The above potential issues with respect to the MAP_ADDRESS can be avoided by
using the “Offset” library instead of the Direct Pointer Arithmetic library. The
“Offset” approach calculates an offset from the beginning address of the inmemory
database, to locate objects. Therefore, it does not depend on the inmemory
database starting at a common (and known) location for all processes.
However, the DP pointer arithmetic is about 5%–15% faster than calculating
offsets.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值