简体   繁体   English

跟踪Java Web应用程序中的内存不足异常

[英]Track out of memory exception in java web application

I am working on a web application which reads file and give me searched string with line number and other details, For that, I am using following technologies: 我正在使用一个Web应用程序,该应用程序读取文件并为我提供带有行号和其他详细信息的搜索字符串,为此,我正在使用以下技术:

  1. Spring MVC 春季MVC
  2. DWR reverse AJAX DWR反向AJAX

FTP and share location files, I am reading using this app. FTP和共享位置文件,我正在使用此应用程序阅读。

Every time , I am doing search, it is showing "outofmemory" exception. 每次执行搜索时,都会显示“内存不足”异常。 is it there any tool available where I can watch which part of code is creating problem exactly? 有没有可用的工具可以让我看到代码的哪一部分正造成问题?

I tried jConsole, MAT and other tools but all are looking complex as I am new in performance testing. 我尝试了jConsole,MAT和其他工具,但由于我是性能测试的新手,所以它们看起来都很复杂。

You can simply try with jVisualVM, which is available with your JDK if you're using a recent version of Java. 您可以简单地尝试使用jVisualVM,如果您使用的是Java的最新版本,则JDK可以使用jVisualVM。 ( docs ) docs

It will give you the ability to hook to a running process, including your local application server, and to generate heap dumps to examine what's heating your memory. 它将使您能够挂接到正在运行的进程(包括本地应用程序服务器),并生成堆转储以检查什么正在使您的内存变热。

It's generally good enough for most low-level memory profiling / mem-leak hunting requirements. 通常,它足以满足大多数低级内存配置/ mem-leak寻找要求。

Though that being said, MAT would probably allow you to do exactly the same thing and has similar complexity, so I suspect you might have to buckle up and read a tutorial or two on how to use it. 话虽这么说,MAT可能会让您做完全一样的事情并且具有相似的复杂性,因此我怀疑您可能需要扎紧并阅读一两个关于如何使用它的教程。 This blogpost gives a decent introduction on analyzing memory leaks in a Java applicationjVisualVM . 该博文对Java应用程序 jVisualVM中的内存泄漏进行了详尽的介绍。

A OutOfMemoryError is thrown when you have too many RAM used. 当您使用过多的RAM时,将引发OutOfMemoryError Try to find out where you store very much data, eg in a List that is never cleared. 尝试找出存储大量数据的位置,例如,一个永不清除的列表。

If you can't find the error, create a Heap Dump. 如果找不到错误,请创建一个堆转储。 Then, open it and look what rubs your memory. 然后,打开它,看看会打磨您的记忆。 A great tutorial is here: https://blog.codecentric.de/2011/08/java-heapdumps-erzeugen-und-verstehen-4-akt/ 一个很棒的教程在这里: https : //blog.codecentric.de/2011/08/java-heapdumps-erzeugen-und-verstehen-4-akt/

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

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