1

我使用valgrind检查通过jni调用 java 方法的 ac 程序的内存泄漏。但即使是最简单的程序,它只创建一个 JVM 并释放它,valgrind也总是报告泄漏。有什么建议吗?

  JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
  (*jvm)->DestroyJavaVM(jvm);

valgrind 输出:

> ==21794== 
> ==21794== HEAP SUMMARY:
> ==21794==     in use at exit: 7,596,470 bytes in 1,427 blocks
> ==21794==   total heap usage: 45,668 allocs, 44,241 frees, 25,184,437 bytes allocated
> ==21794== 
> ==21794== LEAK SUMMARY:
> ==21794==    definitely lost: 4,989 bytes in 24 blocks
> ==21794==    indirectly lost: 5,234 bytes in 22 blocks
> ==21794==      possibly lost: 245,199 bytes in 182 blocks
> ==21794==    still reachable: 7,341,048 bytes in 1,199 blocks
> ==21794==         suppressed: 0 bytes in 0 blocks
> ==21794== Rerun with --leak-check=full to see details of leaked memory
> ==21794== 
> ==21794== For counts of detected and suppressed errors, rerun with: -v
> ==21794== Use --track-origins=yes to see where uninitialised values come from
> ==21794== ERROR SUMMARY: 4040666 errors from 332 contexts (suppressed: 4 from 4)
4

0 回答 0