This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how to know how many objects are unclaimed.? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to know how many objects are unclaimed.?" Watch "how to know how many objects are unclaimed.?" New topic
Author

how to know how many objects are unclaimed.?

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
Hi,

I was wondering if there is any way to know how many objects are present and how many unclaimed by the garbage collector while a program is being run. For instance in a code of 1500 lines there may be numerous objects still alive even though not going to be used.

Which brings me to another question what effect do unclaimed objects have on the efficiency in terms of memory usage.Do unclaimed objects have any effect on the program ?

Regards


Money for nothing and Java for Free
SCJP, SCWCD
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

There's no way (AFAIK) in the standard API to ask the garbage collector how many objects are waiting to be cleaned up.

Ofcourse the garbage collector takes a small amount of processor time, and objects that are not cleaned up take up memory, but you should normally not be concerned with it - the garbage collector contains some very clever algorithms to keep things as efficient as possible.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to know how many objects are unclaimed.?
 
Similar Threads
Question on Heap?
assertion question
Question on Heap?
garbage collection
Objectification and performance