• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

list the objects of particular class.

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all i have some doubts:
1)can we get a list of objects that are presently in memory by passing full class name?
2)can we list classes that are loaded into memory.

thanks,
Sudheer.K
 
Winston Gutkowski
Bartender
Pie
Posts: 10509
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudheer kiran wrote:1)can we get a list of objects that are presently in memory by passing full class name?
2)can we list classes that are loaded into memory.

As far as I know: no - except maybe on a case by case basis - however, you might be able to get some of that information from a profiler.

My question is: Why do you think you need to know this? Java is not C/C++, so memory management is not your concern. And you absolutely should not write programs that rely on that information, or any pattern derived from it, as the memory model may change in the future. I've never needed anything like it in 10 years of using Java.

Winston
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15452
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really want to do this, then it might be possible by using the JVM's debugger API, but that means you're actually writing a debugger for Java programs, which is not a very easy task. There are not some easy to use methods you can call to list all instances of a particular class in the current JVM.
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi thanks for the replies. i just wanted to know if any API is available for quick usage.
i haven't come across a situation but thought of to know if is it possible.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic