如何分析和理解 Java Web 应用程序的输出

发布于 2024-08-02 04:00:28 字数 787 浏览 4 评论 0原文

我目前正在尝试分析一个 Java Web 应用程序。 我将 Netbeans Profiler 与 Eclipse 结合使用。 我的服务器(Tomcat)通过 eclipse 插件运行,我使用 Netbeans profiler 动态连接到服务器。

我有一个主要问题,有时服务器在环境中耗尽内存。 我读到有关内存泄漏的内容,我意识到有两种方法: 1. 内存中的大对象未被收集并导致内存泄漏或 2. 小对象不断在内存中分配而不被收集。

尽管第二个通常很难找到,但一个常见的症状是,在一段时间内,垃圾收集中幸存的代数将不断增加,无论速度如何。 这似乎发生在我的网络应用程序中,尽管没有真正发生任何活动。 世代在一段时间内稳步增长,无一例外。 迫使我认为我在某个地方有一些应该被垃圾收集的引用对象。

我使用探查器运行了测试,但不幸的是我并不真正了解如何精确定位对象。 我注意到,尽管我多次进行垃圾回收,但一个特定的 HASHMAP 的存活代计数持续增加。

我附上一个简单的屏幕截图,简要概述了我在启动应用程序的接下来几分钟内看到的内容。

如果您能给我指出一些真实的文章等,我将不胜感激,这些文章将启发我如何理解分析以及我应该做什么来确保抓住罪魁祸首。

任何帮助深表感谢。

找到所附的屏幕截图。 替代文本 http://dl.getdropbox.com/u/1264228/Files/状态.png

I am currently trying to profile a java web app. I used Netbeans Profiler in conjunction with Eclipse. My server (Tomcat) is running through eclipse plugin and I dynamically connect to server using Netbeans profiler.

I have a primary problem, that after sometime server runs out of memory on an environment. I read about the memory leak and I realized that there are two ways:
1. Large objects sit in memory stay un collected and cause memory leak OR
2. small objects keep getting assigned in memory without being collected.

Although second one is usually hard to find, one usual symptom is that over a period of time, the gerenerations surviving garbage collection would keep increasing, irrespective of speed. And it seems to happen in my web app, although no activity is really taking place. The generations increase over a period of time, steadily and without exception. Forcing me to think that I have some refrenced objects somewhere which should have been garbage collected.

I ran the tests with profiler but unfortunately I don't really understand as to how to pin point the object. I noticed that one specific HASHMAP had surving generation count consistently increasing even though I garbage collected several times.

I am attaching a simple screen shot giving a very brief overview of what I saw in next few min of starting application.

I would be grateful if you could point me out to some real articles etc which would enlighten me as to how to make sense of profiling and what is it that I should go about doing to ensure I catch the culprit.

Any help is much appreciated.

Find the screenshot attached.
alt text http://dl.getdropbox.com/u/1264228/Files/State.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我做我的改变 2024-08-09 04:00:28

检测任何应用程序(Java 或非 Java)中内存泄漏的最佳方法是在应用程序使用时定期拍摄内存快照,然后仔细检查应用程序管理的不同类型对象的对象计数。

大多数内存泄漏可以追溯到一组内存消耗增加最多的对象。 简而言之,应该优先考虑 Δ MEM(对象)而不是 Σ MEM(对象)。

一旦确定了导致泄漏的对象集,您就需要通过对象分配跟踪来查明泄漏源。

有关如何使用 Netbeans 执行此操作的快速介绍,您可以查看 Java 激情

在 Eclipse 中,您会发现 MAT 插件描绘支配树的能力非常有用。

最后,以下术语列表将很有用,因为有效的分析需要先了解这些术语:

The best way to detect a memory leak in any application (Java or not) is to take periodic snapshots of memory, while the application is in use, followed by a close examination of the object count for the different types of objects managed by the application.

Most memory leaks can be traced to a group of objects that show the largest increase in memory consumption. Briefly stated, one should give priority to Δ MEM(objects) as opposed to Σ MEM(objects).

Once you have identified the set of objects responsible for the leak, you then need to pinpoint the source of the leak, via the object allocation trace.

For a quick introduction, on how to do this with Netbeans, you can take a look at one of the tutorials at Java Passion.

In Eclipse, you will find the MAT plugin's ability to depict the dominator tree to be very useful.

Finally, the following list of terms would be useful, since efficient analysis requires knowledge of these as pre-requisites:

玉环 2024-08-09 04:00:28

我通常每隔几秒钟进行几次堆转储,只是为了查看正在释放的内容和可能保留的内容的模式。

然后,我深入研究可疑的对象,并找到保存对它们的引用的内容。 通常,它可以归结为某些资源未正确关闭、过度使用会话对象、静态变量、某些类加载器、内存缓存或列表中仍在引用的某些对象中的泄漏。

浏览成百上千的物体并解释正在发生的事情并不总是那么容易。 我发现这个关于 JavaPassion 的课程对初学者非常有帮助。

I generally take a couple of heapdumps each few seconds apart just to see the pattern of what is being released and what might be sticking around.

Then I drill down into the objects that are suspicious and find what is holding the reference to them. Often it boils down to some resources not being closed properly, excessive use of session objects, static variables, leaks in some class loaders, inmemory cache or some object in a list that is still being referenced to.

It not always easy to go through though hundreds and thousands of objects and interpret what's going on. I have found this course on JavaPassion to be very helpful to a beginner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文