Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Test and Performance Tools Platform (TPTP) » Memory leak analysis
Memory leak analysis [message #103965] Tue, 10 July 2007 02:27 Go to next message
Andrew Zahra is currently offline Andrew ZahraFriend
Messages: 1
Registered: July 2009
Junior Member
I am just trying out TPTP memory analysis with a small test program to see
how it works. When I run a basic memory analysis with the following
example, I don't see any correlation of the results that would actually
help me find the "problem" in this manufactured example.

The Memory Statistics show char[], byte[], short[] and int[] being the
largest numbers of instances. But there is no connection back to my test
code and I am surprised to no have java.lang.Integer even listed.

The Object References view also provides no more info, being similarly
flat and without any connection back in to my test code.

Contrast this with running the same code under Netbeans profiler and I get
a large number of java.lang.Integer objects and a stack trace to the
source.

Am I missing something? How do I actually get useful info out of the basic
memory analysis?

Thanks in advance... sample code follows.

package mt;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MemTest {

private List hog = new ArrayList();

public MemTest()
{

}

public void doStuff()
{
Iterator iter = hog.iterator();

int i=0;

while (iter.hasNext())
{
i++;
iter.next();
}

System.out.println("count = "+i);
}

public void createStuff()
{
for (int i=0; i<100; i++)
{
hog.add(new Integer(i));
}
}

/**
* @param args
*/
public static void main(String[] args)
{
MemTest mt = new MemTest();

for (int i=0; i<100; i++)
{
mt.doStuff();
mt.createStuff();

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

}
Re: Memory leak analysis [message #105664 is a reply to message #103965] Thu, 19 July 2007 06:27 Go to previous message
Asaf Yaffe is currently offline Asaf YaffeFriend
Messages: 333
Registered: July 2009
Senior Member
Andrew Zahra wrote:
> I am just trying out TPTP memory analysis with a small test program to
> see how it works. When I run a basic memory analysis with the following
> example, I don't see any correlation of the results that would actually
> help me find the "problem" in this manufactured example.
>
> The Memory Statistics show char[], byte[], short[] and int[] being the
> largest numbers of instances. But there is no connection back to my test
> code and I am surprised to no have java.lang.Integer even listed.
>
> The Object References view also provides no more info, being similarly
> flat and without any connection back in to my test code.
>
> Contrast this with running the same code under Netbeans profiler and I
> get a large number of java.lang.Integer objects and a stack trace to the
> source.
>
> Am I missing something? How do I actually get useful info out of the
> basic memory analysis?
>
> Thanks in advance... sample code follows.
>

Hi Andrew,

Thank you for your interest in TPTP.

Have you tried the new Heap Profiler in TPTP 4.4? Although not as mature
as the Netbeans profiler, it provides accurate allocation details and
can trace allocations to their source (but without a full stack trace).

To use the new profiler:
1. Install Eclipse 3.3
2. Install TPTP 4.4 (latest patch, 4.4.0.1 is recommended)
3. Launch Eclipse with a Java 5 (or 6) JVM.
4. Configure a Heap Profiling session, double click the Memory Analysis
collector in the Monitor tab, and select the "Track Object Allocation
Sites" option.

Note that your example will not work properly with the default filter
set, as java.lang.* objects (e.g., Integer) are excluded by default), so
make sure you change this filter before starting to profile.

HTH,
Asaf

--
Asaf Yaffe
Eclipse TPTP Committer, JVMTI Profiler
Previous Topic:Is Object.wait() time included in Cumulative Time?
Next Topic:Profiling Jboss 4.0.3SP1 with TPTP 4.4 from europe build
Goto Forum:
  


Current Time: Thu Apr 25 11:38:26 GMT 2024

Powered by FUDForum. Page generated in 0.02983 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top