Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JProfiler Help

 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just installed JProfiler, evaluation version copy in my machine. I have made the initial configuration and settings.

Now I want to use that for testing my stand alone java program and not for web applications or anything. I just want to find how many objects are getting created and so on.

But I am not able to get the accurate results. for e.g if I have 3 objects of String and 2 of StringBuffer, it shows many values like byte[], int, class and all including the count of String and StringBuffer objects. But the no is wrong, like for String it shows 46 instead of 3 and so on. I am not sure if I did the configuration correctly.

Can anyone help me in this issue, I have tried reading the help documents, but couldnt help myself.

Thanks
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vjy chin:

But I am not able to get the accurate results. for e.g if I have 3 objects of String and 2 of StringBuffer, it shows many values like byte[], int, class and all including the count of String and StringBuffer objects. But the no is wrong, like for String it shows 46 instead of 3 and so on. I am not sure if I did the configuration correctly.


JProfiler doesn't only show you the number of objects your code creates directly, but of *all* objects in the VM. It's likely that your code causes more objects to be created behind the curtain than you are aware of.

Can you show us the code you are profiling?
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code I am using


Also I used the Thread.sleep method, since the profiler jvm window closes immediately after the operation. So I just gave a delay.

Thanks
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mhh, I don't see how your code creates any Strings at all - probably the VM does something in the background (try it with a program that *only* contains the sleep). If I remember correctly, JProfiler can show you from where objects are referenced, and thereby give you a good idea of why they exist at all.
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Can you tell me where I can look for the objects and where they are being referenced from. What settings should I do?

Also do you want me to run only with the thread.sleep()?
Thanks again
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently on vacation and don't have access to JProfiler, so I can't help you with the details, sorry...
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks dude, You can let me know after you are back from your vacation.

BTW, have a nice vacation.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic