Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (2024)

Table of Contents

  • June 7, 2016
  • December 27, 2023
  • Avani Patel
  • Blog
  • Embedded Software Developement

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT)

Enterprises today depend on high performance, in-memory applications more than ever before. Whether you use BI/Analytics, SaaS, sales and marketing automation, virtualization, real time collaboration, Web 2.0 or software product engineering tools, it is expected that important business questions should be answered in the fraction of a second. To ensure that, analyzing memory becomes a very crucial task.

With the increasing blurring of boundaries between transactional (OLTP) and analytical (OLAP) data management systems, the trend of separate databases is dying out making memory analysis complicated and confusing. Also, at the time of code development, it is difficult to assess an application’s memory usage in the actual production environment. The code alone does not help much in figuring out which object would consume more memory. In order to have advanced diagnostics capability, developers should be mindful of garbage collection at the time of writing code itself. Let’s say, we have an array of objects “userMap”, which stores the data of logged in users and session ids. For this array, if we forget to remove unused array object references in code, the memory consumed by these objects may never be reclaimed resulting in out of memory conditions/server crash.

Tools like Garbage Collector (GC) provide automated memory management. An object is eligible for garbage collection when no live thread can reach it which means there are no references to that object. Having said that, GC may not be able to reclaim all unused object memory. In such situations, it is easy to run out of memory resulting in application crashes/hang-ups.

Eclipse’s open source-based Memory Analyzer tool (MAT) is being extensively used in engineering products and service designs to help track those pesky bugs. Here, I will share the biggest advantages of working with MAT based on my experience in our ongoing project with a leading home automation player in the US. We have been able to achieve the following results:

  • Closing down on memory leaks down to smallest sized bits
  • Improved application performance
  • Improved timing

What is Memory Analyzer Tool (MAT)?

The Memory Analyzer Tool (MAT) is a plugin in Eclipse for Java heap memory troubleshooting to find memory leaks and reducing memory consumption.

Let’s take a simple example in analyzing memory. First install MAT plugin in Eclipse [eclipse -> Help -> Install New Software -> Give this URL: http://download.eclipse.org/mat/1.5/update-site/].

The sample code acquires lots of heap sizes resulting in “OutOfMemoryError” error.

In run configuration settings, in VM arguments, add “-XX:+HeapDumpOnOutOfMemoryError” and run the application. You will see a message “Heap dump file created”.

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (1)

By clicking on dumb file, MAT wizard opens. Select “Leak Suspects Report” which opens system overview report and displays possible problem suspects in pie chart.

MAT also gives histogram for classes and objects. It gives all the information connected to loaded classes, ‘super classes’ name, loader of class, class’ static fields, Objects of class, size of collection used etc.

– Histogram example.

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (2)

Leak suspect report example :

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (3)

MAT also gives the following features below:

  • Dominator Tree: List the biggest objects and how they are kept alive,
  • Top Consumers: Print the most expensive objects grouped by class and by package,
  • Duplicate Classes: Detect classes loaded by multiple class loaders.

This basic understanding of memory analyzer tool makes it clear that Eclipse MAT is very helpful to developers to track leaks and other bugs related to memory. Developers can find root cause very quickly which is very difficult to do by studying code. In summary, this helps clients get close to high performance applications. We would be happy to hear your own ideas on how memory applications can be speeded. If you want more information on this topic or drop in new suggestions, you’re welcome to email us at marketing@einfochips.com

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (4)

Avani Patel

Avani Patel works at eInfochips as Engineer. She holds a Master's degree in Information Technology from Dhirubhai Ambani Institute of Information and Communication Technology [DA-IICT], Gandhinagar. She has contributed consistently into successful execution of application development projects for ISV. She has a sound knowledge in technologies like Java, J2EE, Struts, Spring, OO JavaScript and many others.

Explore More

Press Release

eInfochips joins TSMC Design Center Alliance to Accelerate Semiconductor Innovation

Read More »

Blog

Common Myths About Automation QA

Read More »

Case Study

Automotive Functional Safety Mechanism

Read More »

Blog

Secure by Design Principles for External Accessible Interfaces

Read More »

Blog

Mastering Git: A Comprehensive Tutorial for Developers

Read More »

Blog

Instant Apps: What are they? How useful is it for your business?

Read More »

View All

Talk to an Expert

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (11)

Subscribe
to our Newsletter

Stay in the loop! Sign up for our newsletter & stay updated with the latest trends in technology and innovation.

Preventing Server Crashes and Memory Leakage with Eclipse Memory Analyzer Tool (MAT) (2024)

References

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 6444

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.