简体   繁体   English

从动态库调用jni时,JVM堆的内存不足

[英]Not enough memory for JVM heap when calling jni from dynamic library

I have strange situation: we have .dll library (lets call it 'sdk_wrapper'), which is wrapper for java classes, which are opening JRE jvm.dll and use some other .dlls (PKCS11 implementations, to be more specific - but I think it doesn't matter). 我有一个奇怪的情况:我们有.dll库(我们称其为“ sdk_wrapper”),该库是Java类的包装器,这些类正在打开JRE jvm.dll并使用其他一些.dll(PKCS11实现,具体而言,但我认为没关系)。

Everything works fine when I use sdk_wrapper directly in my c++ program (alias 'run_dll'). 当我直接在我的C ++程序中使用sdk_wrapper时,一切工作正常(别名为“ run_dll”)。 But when I pack it into another .dll (to prepare configurations file, initialize library, etc) and export one function which is dong everything the same as program 'run_dll', calling this causes jvm initialization error: Could not reserve enough space for object heap . 但是,当我将其打包到另一个.dll(以准备配置文件,初始化库等)并导出与程序“ run_dll”相同的一个函数时,调用此函数将导致jvm初始化错误: Could not reserve enough space for object heap JVM.dll initialization is doing with -Xmx512m . JVM.dll初始化使用-Xmx512m

Have you any idea what's going on? 你知道发生了什么吗? I readed that JVM needs continous part of memory to initialize, but what's the difference between calling 'sdk_wrapper' directly from program and from another dll? 我读到JVM需要连续的一部分内存来初始化,但是直接从程序和另一个dll调用'sdk_wrapper'有什么区别? They are at the same place (I mean in the same directory). 它们在同一位置(我的意思是在同一目录中)。

As you load libraries into a memory, you end of with memory fragmentation of the address space. 当您将库加载到内存中时,您将以地址空间的内存碎片结束。 Win32 is particularly bad for this. Win32对此特别糟糕。

Note: if you use a 64-bit process this isn't an issue as you will have plenty of virtual memory. 注意:如果您使用64位进程,这不是问题,因为您将拥有大量的虚拟内存。

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

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