The Artima Developer Community
Sponsored Link

Java Community News
Insane Project Releases 1.1 Version of Java Heap Analysis Tool

1 reply on 1 page. Most recent reply: Nov 27, 2006 1:51 AM by bug not

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Insane Project Releases 1.1 Version of Java Heap Analysis Tool Posted: Nov 24, 2006 9:54 AM
Reply to this message Reply
Summary
According to its creator, Petr Nejedly, Insane is a "post-mortem memory leak analysis tool," and has its roots in the NetBeans IDE. Insane performs heap analysis by introspecting an application from within, and requires no profiler-related instrumentation of the code.
Advertisement

While memory profilers are the most common way to gauge an application's memory use, using a profiler exclusively for that purpose has a few drawbacks, according to Petr Nejedly, creator of the Insane heap analysis tool:

Profiling structures using profiler needs complicated instrumentation and is hard to perform automatically from memory regression tests... Long-term running the application in the instrumented environment significantly reduces its performance and you need to prepare instrumentation in advance.

To solve these problems, Nejedly created what he calls a "post-mortem memory leak analysis tool," Insane. Nejedly released Insane 1.1 yesterday.

According to Nejedly, Insane can be used either to measure the size of a data structure in memory, or to analyze the entire heap, and both modes are based on the same memory scanning engine:

The engine performs a BFS scan of the object graph from [a] given collection of roots, counting visited instances of each type and their size. The size computation is based on the Sun JDK1.3/1.4 storage format and for these JDKs is exact. The engine puts each newly found object into an identity map, assigns it unique ID and adds it to the end of processing queue. Already known objects are ignored. Processing ends when the queue is empty—the algorithm has traversed full transitive closure of [the] given roots.

The engine is able to skip some objects, specifically java.lang.Class instances, instances of its own classes and instances from the user filter. The output of the engine is the size distribution collection, containing instance count and total size of each found class.

When measuring the size of an object in memory, Insane allows you to specify a root collection that references the object to measure.

In the heap analysis mode:

The tool does a best effort to find all the real JVM GC roots using introspection on all known classloaders and evaluating the static references. This is also the limitation of the tool - it can't find stack-local and JNI references, but it is only a marginal problem in the event-driven application domain.

In this mode, the tool uses a visitor pattern to notify all found objects and all the references between objects. The default implementation of the visitor logs all the information to a simple format XML file.

The resulting XML output can be large, depending, of course, on the size of the heap. However, the XML format is self-describing, and is amenable to easy input into other tools:

The format of the file ... is self-describing, there are only two types of tags, object and ref. The object tags carry ID, name, size of the instance and, in case the type is [C[character array], the textual representation of the character array. The ref tags are either static references, carrying the fully qualified field name and the ID of the referenced object, or instance references, carrying also the ID of the referring object.

What do you think of the idea of introspecting the heap from within a running application? And what are some of the limitations you encounter with a more traditional memory profiler?


bug not

Posts: 41
Nickname: bugmenot
Registered: Jul, 2004

Re: Insane Project Releases 1.1 Version of Java Heap Analysis Tool Posted: Nov 27, 2006 1:51 AM
Reply to this message Reply
> What do you think of the idea of introspecting the heap
> from within a running application? And what are some of
> the limitations you encounter with a more traditional
> memory profiler?

This is exactly what I do in my open-source monitoring utility: MessAdmin (http://messadmin.sourceforge.net/).
Given an object root, I compute the size of said object by reflecting upon its graph. Note that you may encounter this nasty bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5012949 for which I have some kind of workaround.

Flat View: This topic has 1 reply on 1 page
Topic: iText Java PDF Library 1.4.7 Released Previous Topic   Next Topic Topic: Ruby on Rails 1.2 Release Candidate Available

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use