简体   繁体   English

如何诊断由Java程序引起的C内存泄漏?

[英]How do you diagnose a leak in C memory caused by a Java program?

I'm working on a large application (300K LOC) that is causing a memory leak in the Sun 1.6 JVM (1.6_05). 我正在处理一个在Sun 1.6 JVM(1.6_05)中导致内存泄漏的大型应用程序(300K LOC)。 Profiling the Java shows no leak. 分析Java显示没有泄漏。 Are there any diagnostics available from the JVM that might detect the cause of the leak? JVM中是否有可用于检测泄漏原因的诊断信息?
I haven't been able to create a simple, isolated Java test case. 我无法创建一个简单,孤立的Java测试用例。 Is the only way to figure this out by using a C heap analyzer on the JVM? 通过在JVM上使用C堆分析器来解决这个问题的唯一方法是什么?
The application creates a pool of sockets and does a significant amount of network I/O. 该应用程序创建一个套接字池并执行大量的网络I / O.

Some profiler like profiler4j can show the managed and the unmanaged memory (live curve). 像profiler4j这样的一些分析器可以显示托管和非托管内存(实时曲线)。 Then you can see if you has a leak and when the leak occur. 然后,您可以查看是否有泄漏以及何时发生泄漏。 But you does not find more informations. 但是你找不到更多的信息。

After this there are 2 possible solutions: 在此之后有两种可能的解决方案:

  1. You can with the live curve isolate the problem and create a simpler test until you have find the cause of the problem. 您可以使用实时曲线隔离问题并创建更简单的测试,直到找到问题的原因。
  2. You search your code for the typical problems like: 您在代码中搜索典型问题,例如:
    1. Instances of the class Thread that are never start. 从不启动的类Thread的实例。
    2. Images or Graphics that never are dispose 永远不会丢弃的图像或图形
    3. ODBC Bridge Objects that are never close ODBC桥从不关闭的对象

I love valgrind ( http://valgrind.org/ ), if you are executing it on a system it supports. 我喜欢valgrind( http://valgrind.org/ ),如果你在它支持的系统上执行它。 It really rocks! 它真的很摇滚!

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

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