• Post Reply Bookmark Topic Watch Topic
  • New Topic

number of classes loaded..  RSS feed

 
V Chauhan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When a class is first encountered in code, it is loaded into memory by the JVM. I wanted to know is there a way we can know the number of such classes, i.e., which are loaded by the JVM.
Hope my question makes some sense.
Thanks in Advance,
Basu.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java 1.5, JMX will provide a class/method to do this. It doesn't help for now, but it's worth keeping in mind for the future.
How come you need/want to know how many classes are loaded?
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few JVM querying tools out there.
For what you want to do, I'd try JMP - it's free and simple. I've had limited success with it - it seems to work OK for small programs, but I was unable to profile a larger (1000 class / 500k line) J2EE app. I'm using Java 1.3.1 so that may play a part.
Anyway, you can get JMP from http://www.khelekore.org/jmp/. Installation wasn't too difficult, and the end result is you do java -Xrunjmp MyMainClass to get a few windows with stats about classes loaded, methods called etc.
On a side note, if anyone has had success on bigger projects with any free profilers I'd be keen to hear from them.
Hope this helps.

--Tim
 
V Chauhan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answers..
The reason why I want to know about this is, there is a weblogic configuration parameter (maxPermSize) which impacts the number of classes that can be loaded into JVM. So I wanted to do some testing to co-relate the value of this parameter and the number of classes loaded successfully.
Let me see if JMP can be useful for me bcoz its a J2EE app with thousands of class files.
Basu.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mine is also a WebLogic app - from what you say I imagine they're of the same order of magnitude.
I couldn't get it going - it'd work until it'd loaded maybe 90 classes during WebLogic startup, then hang.
If you manage to get it going let me know how!
Cheers,

--Tim
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!