This discussion is archived
0 Replies Latest reply: May 14, 2012 12:17 AM by 800839 RSS

Profiling a standlone java class with VisualVM

800839 Newbie
Currently Being Moderated
Hi,

I have written a java class which contains an infinite loop which throws an OutOfMemoryError , I want to profile this Standalone class.
public class OutOfMemoryTest1 {

/**
* @param args
*/
public static void main(String[] args) {
ArrayList<Object> list = new ArrayList<Object>();

try {
while ( true )
list.add( new Object() );
} catch ( OutOfMemoryError e ) {
// And we are done...
System.out.println("the exception is:"+e);
}


}

}

Hence i am using VisualVM which is under jdk1.6.0_16. I am using Eclipse launcher for VisualVM for that java class by doing the below:-

Run as -> Select the Visual VM launcher as supposed to Eclipse JDT launcher. Which detects the respective file in the VisualVM explorer.
I am able to get the profiler tab as well as other tabs like overview,monitor,threads. But when I click the profiler tab and select the
"Memory" button , I am getting a popup which contains "Connecting to the target VM" with the status : Profiling started and Progress bar
is going on..on..on. But it is not stopping what might me the problem here. Because of this I am unable to profile the respective java class.
Please clarify.

Thanks.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points