Tuesday, February 16, 2010

Eclipse Memory Utilisation

On my PC, Eclipse is currently hogging 518 MB of RAM! Want to find out why Eclipse is using up so much memory? This is how:
  • Find the process id of Eclipse. You can use the jps command to help.
  • Now dump out the java object heap using the jmap command. For example: jmap -dump:format=b,file=C:\temp\eclipse_heap.bin 3080
  • Open the heap file (C:\temp\eclipse_heap.bin) in Eclipse.
Eclipse will take a couple of minutes to load the object heap into its Memory Analyser. It will then provide lots of useful information such as:
  • A Leak Suspects Report: My main suspect was org.maven.ide.components.nexus_indexer occupying 24,201,456 (24.29%) bytes.
  • A Histogram which lists the number of instances per class. There were 583,760 char[] objects and 439,572 String objects on my heap.
  • Dominator Tree which lists the biggest objects and what they keep alive. Mine were:
    • org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader @ 0x3f46368 org.maven.ide.components.nexus_indexer (23.1 MB)
    • org.eclipse.jdt.internal.core.JavaModelManager @ 0x4710728 (15.2 MB)
    • org.eclipse.jdt.internal.core.search.indexing.IndexManager @ 0x475c3e8 (9.7 MB)
    • org.eclipse.jdt.internal.ui.text.spelling.SpellCheckEngine @ 0x3d617a8 (6.5 MB)
  • Top Consumers which lists the most expensive objects grouped by class and package.
As a result of my findings, I have now removed the Maven Plugin and have also disabled the Spell Checker. Memory is down to 356 MB and the biggest object is org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager (26.1 MB).

Further Reading:
Eclipse Memory Analyzer, 10 useful tips/articles

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.