views:

39

answers:

1

Using the Eclipse profiler, I am interested in number of allocated instances of classes from java.lang (for instance String). I also want to know stuff like number of calls to String.equals() etc.

I use the "Object Allocations" tab and I shows all classes in my application and a count, but there is no mention of any standard java classes.

For instance, this silly code shows up in the Object Allocations tab as 1000 Foo, 7 byte[], 4 char[] and 2 int[]. Nothing else.

public static void main(String[] args) 
{
    Object obj[] = new Object[1000];
    for (int i = 0; i < 1000; i++) {
        new Foo();  // Some custom class
        obj[i] = new StringBuffer("foo" + i);
    }
    System.out.println (obj[30]);
}

It seems the profiler simply ignores everything that is in any of the java.* packages. The same applies to Execution Statistics as well.

Do I need to enable instrumentation for the core java classes or is there some setting I am missing here?

A: 

If you're using the same Eclipse profiler listed here you need to set the inclusion/exclusion filters up. In your case, you can add a particular package or class to the inclusion filter, or simply remove it from the exclusion filter pre-defined. I would go with the former as its the more conservative approach and will most likely have a lower impact on your application performance. Removing something from the exclusion filter may result it removing more than you intended or wanted, meaning that more code is instrumented.

Amir Afghani
Ah yes, I found it! For the record, the setting is in Profile Configuration/Monitor. Then select "Java Profiling - JRE 1.5 or newer" in the tree and click "Edit Options".
Martin Wickman