我使用 valgrind 来检查通过 jni 调用java方法的c程序的内存泄漏。但即使对于只创建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)