Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remotely identify a memory leak in an application used by a customer

A customer is complaining that he's experiencing a memory leak in our Java application.

Despite all my efforts to reproduce his environment, configuration and usage, I wasn't able to reproduce, and thus identify, the leak.

I'd want to go down another path... Instead of trying to replicate it, maybe I could ask him to generate some view of his heap that would allow me to identify the leak.

Being run by the customer who would send it to me, there are some requirements on this:

  1. Should not contain confidential info
  2. Should be small enough that it can be sent through the internet
  3. Should be generated by an easily available tool (would be best if it was in the Java distribution)

A complete heap dump is impossible because of 1. and 2.

Most of all, it should allow me to find the leak. So it should at least show the retained heap size for objects of each class (size of itself + everything it keeps a reference to). jmap -histo is definitely not good enough.

 num     #instances         #bytes  class name
----------------------------------------------
   1:         14156      577318512  [B
   2:          9196       47439696  [I
   3:         83396        9809992  [C

Is something like that useful at all? I don't think so.

like image 632
Gohu Avatar asked Mar 01 '12 10:03

Gohu


People also ask

How do I find a memory leak on an application?

To find a memory leak, look at how much RAM the system is using. The Resource Monitor in Windows can be used to accomplish this. In Windows 8.1 and Windows 10: To open the Run dialogue, press Windows+R, then type "resmon" and click OK.

How can you tell if a program has a memory leak?

The primary tools for detecting memory leaks are the C/C++ debugger and the C Run-time Library (CRT) debug heap functions. The #define statement maps a base version of the CRT heap functions to the corresponding debug version. If you leave out the #define statement, the memory leak dump will be less detailed.

What is the best tool to detect memory leaks?

To find memory leaks and inefficient memory usage, you can use tools such as the debugger-integrated Memory Usage diagnostic tool or tools in the Performance Profiler such as the . NET Object Allocation tool and the post-mortem Memory Usage tool.


1 Answers

Without knowing a bit more about you and your customers it is hard to comment but in my experience a customer telling me we have a memory leak (especially in Java) just means "customer's system has some problem that may or may not be related to our app"

I'd start by something as simple a finding out why he thinks your app has a leak (i.e. ps or task manager output showing process sizes)

like image 122
John3136 Avatar answered Nov 08 '22 02:11

John3136