Friday, December 27, 2013

I have a production server running with the following flag: -XX:+HeapDumpOnOutOfMemoryError
Last night it generated a java-38942.hprof file when our server encountered a heap error. It turns out that the developers of the system knew of the flag but no way to get any useful information from it.
Any ideas?
share|improve this question
add comment

5 Answers

up vote66down voteaccepted
If you want a fairly advanced tool to do some serious poking around, look at the Memory Analyzer projectat Eclipse, contributed to them by SAP.
Some of what you can do is mind-blowingly good for finding memory leaks etc -- including running a form of limited SQL (OQL) against the in-memory objects, i.e.
SELECT toString(firstName) FROM com.yourcompany.somepackage.User
Totally brilliant.
share|improve this answer
I'd just like to add a +100 for Eclipse Memory Analyzer. I'm currently attempting to sift thru a 400mb+ heap dump file, and it took jhat more than 70 minutes to read the file, before it caused a complete JVM crash. EMA is able to open it up in < 5 minutes. –  matt b Jun 18 '09 at 18:37
Too bad MAT often fails to read heaps... :-( –  Vladimir Dyuzhev Apr 1 '10 at 14:55
I keep getting parsing errors when opening HPROF files using the Eclipse Memory Analyzer (that were in fact also dumped by Eclipse!). Unfortunate.. sigh. –  lost_bits1110 Dec 14 '11 at 22:16 
add comment

I suspect we have a major memory leak in our ActiveMQ connection bridge - we're seeing typical memory leak patterns (app loads fine, slows down if it runs for prolonged periods of time or is restarted over and over again over short periods of time). I looked up modern best practices for finding Java memory leaks and a lot of developers seem to be abandoning traditional tools like jhat/jmap in lieu of the new(er)jvisualvm.
Upon launching this tool (and spending a few hours reading over its tutorial) I am able to take profiler snapshots for both CPU and memory.
I'm just sort of stuck at this point - how do I analyze these snapshots to identify the leak? There's a plethora of documentation out there as to how to use jvisualvm to produce snapshots, but very little documentation as to how to actually make sense of them.
Thanks in advance.
share|improve this question
Have you tried running FindBugs over the source? I find that pretty effective at identifying code that could cause memory leaks. –  Jivings Feb 6 '12 at 2:01
Thanks for the suggestion - but two things: (1) I've been told over and over again that FindBugs is good for NullPointerExceptions but not memory leaks, and, more importantly, (2) I really want to get familiar with jvisualvm, so unless it is clearly not the right tool for this job, I'm interested to see how it is used as a diagnostic tool. Thanks again for the good suggestion though! –  IAmYourFaja Feb 6 '12 at 2:17
One little thing: Tools/Plugins/Available Plugins -- install Visual GC -- the plugin shows better graph of your heap memory and GC status. –  coolcfan Feb 6 '12 at 3:28
add comment
Analysing memory leak using visualvm is not that easy. It has a tool/plugin called 'sampler'. This can be used to sample memory or cpu. You can take snapshot at regular interval and look for possible leaks. Here is some details on how to use it- Obtained from quick search
More effective way will be to get a heap dump (say when the application has slowed down or when OOM happens). VisualVM help you to take heapdump (using Heap Dump on Monitor tab)
This file can be analysed by MAT- Some details are here at How do I analyze a .hprof file? and
share|improve this answer
add comment


oakleyses said...

louis vuitton handbags, oakley sunglasses, louboutin, longchamp outlet, nike shoes, louis vuitton outlet stores, chanel handbags, burberry outlet, prada outlet, jordan shoes, tiffany and co, michael kors outlet, tory burch outlet, louis vuitton outlet, longchamp handbags, nike free, true religion jeans, michael kors outlet, kate spade outlet, polo ralph lauren outlet, tiffany and co, prada handbags, polo ralph lauren outlet, michael kors outlet, michael kors outlet, longchamp handbags, oakley sunglasses, ray ban sunglasses, kate spade handbags, burberry outlet, louis vuitton outlet, louboutin outlet, louboutin, coach factory outlet, air max, air max, coach outlet, gucci outlet, christian louboutin shoes, michael kors outlet, coach purses, ray ban sunglasses, michael kors outlet, louis vuitton, coach outlet store online, true religion jeans, oakley sunglasses cheap

oakleyses said...

ralph lauren, lululemon, air max, hollister, north face, nike air max, polo lacoste, vanessa bruno, timberland, vans pas cher, louboutin, louis vuitton, oakley pas cher, air max pas cher, nike roshe run, air max, true religion outlet, barbour, sac longchamp, air force, hollister, sac louis vuitton, nike free, polo ralph lauren, nike trainers, louis vuitton uk, nike roshe, sac hermes, longchamp, michael kors, sac burberry, sac guess, mulberry, new balance pas cher, converse pas cher, sac louis vuitton, hogan outlet, nike tn, north face, true religion outlet, ray ban pas cher, michael kors, air jordan, nike blazer, nike free pas cher, michael kors pas cher, abercrombie and fitch, ray ban sunglasses

oakleyses said...

mac cosmetics, mont blanc, marc jacobs, canada goose outlet, nike huarache, vans shoes, soccer jerseys, hollister, giuseppe zanotti, beats by dre, abercrombie and fitch, longchamp, insanity workout, celine handbags, bottega veneta, ghd, nfl jerseys, north face outlet, chi flat iron, ugg boots, birkin bag, ugg australia, canada goose, herve leger, ugg pas cher, rolex watches, valentino shoes, canada goose uk, canada goose, ferragamo shoes, canada goose, ugg boots, uggs outlet, north face jackets, soccer shoes, asics running shoes, new balance shoes, p90x, lululemon outlet, canada goose jackets, mcm handbags, instyler, babyliss pro, ugg, wedding dresses, jimmy choo outlet, reebok outlet, nike roshe run

oakleyses said...

parajumpers, karen millen, air max, converse, pandora charms, moncler, louboutin, moncler, links of london, lancel, juicy couture outlet, oakley, hollister, pandora charms, supra shoes, thomas sabo, canada goose, gucci, wedding dresses, timberland boots, swarovski crystal, air max, coach outlet store online, moncler, ray ban, canada goose, moncler, ugg, louis vuitton, swarovski, hollister, montre homme, moncler, hollister clothing store, ralph lauren, rolex watches, moncler outlet, moncler, iphone 6 cases, baseball bats, juicy couture outlet, toms shoes, vans, pandora jewelry, ugg, converse shoes

Zheng junxai5 said...

nike roshe run
coach outlet
adidas yeezy
kobe shoes 11
louis vuitton bags
red bottom shoes
adidas running shoes
cheap jordan shoes
coach factory outlet
louis vuitton outlet
michael kors handbags
louis vuitton handbags
michael kors outlet
adidas outlet store
retro 11
nike outlet
adidas yeezy
coach outlet online
ray bans
coach factory outlet online
hermes birkin handbags
insanity workout
adidas wings
toms shoes
air jordan shoes
nike trainers women
burberry handbags
ralph lauren outlet
oakley sunglasses wholesale
nike roshe one
cheap rolex watches
louis vuitton outlet
michael kors outlet clearance
cheap ray ban sunglasses
nike store
cheap jerseys
adidas factory outlet
tiffany and co
ray ban outlet