简体   繁体   English

JVM堆外内存地址是否有变化?

[英]JVM off-heap memory address subject to change?

We have a platform which heavily relies on off-heap memory in JVM. 我们有一个很大程度上依赖于JVM中的堆外内存的平台。 We noticed that, from time to time, we get SIGSEGV during the GC cycle: 我们注意到,在GC循环期间,我们不时得到SIGSEGV:

V  [libjvm.so+0x5c56cf]  G1ParScanThreadState::copy_to_survivor_space(InCSetState, oopDesc*, markOopDesc*)+0x4bf

I completely understand that those are quite hard to track down, but we have started narrowing down the root case. 我完全理解那些很难追查,但我们已经开始缩小根案例。

The question: 问题:

If I do: 如果我做:

base = unsafe.allocateMemory(capacity);

and, obviously, retain the base for later deallocation, can (in any way) GC get involved and choose to move my native memory? 并且,显然,保留base以便以后解除分配,可以(以任何方式)GC参与并选择移动我的本机记忆?

I know that GC should have no impact on this kind of memory, but I am looking for kind of authoritative answer to this. 我知道GC应该对这种记忆没有影响,但我正在寻找一种权威的答案。

That will return some virtual address pointer and AFAIK unsafe.allocateMemory will just call malloc internally. 这将返回一些虚拟地址指针,AFAIK unsafe.allocateMemory将在内部调用malloc Being an off-heap memory, obviously GC will not touch it and that would be tremendously bad and unexpected if you later would do Unsafe.freeMemory with that pointer, to only find out that it moved. 作为一个堆外内存,显然GC不会触及它,如果你以后会用该指针执行Unsafe.freeMemory ,那将是非常糟糕和意外的,只是发现它移动了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM