File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes Tool for finding Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "Tool for finding "unused" objects?" Watch "Tool for finding "unused" objects?" New topic
Author

Tool for finding "unused" objects?

Ben Ethridge
Greenhorn

Joined: Dec 20, 2002
Posts: 6
Hi, all.
Anyone know of a tool (free or not) for hunting down objects which your code creates but never actually uses?
For example:
x = new MyUnusedObject();
y = new MyUsedObject();
x = y;
...
I know this isn't syntactically correct, but I think you will see the idea. x object reference now points to the object pointed to by the y reference, and MyUnusedObject address space is now "orphaned". In the above example, wouldn't the orphaned MyUnusedObject memory need to be garbage-collected?
If so, and if this coding mistake is done often, could be a signif performance hit. It would be nice to have a way to quickly and easily hunt these down in large code bases.
A run-time hunter would be ok, but one that can scan source (or byte code) would be better. Does not have to find 100% of them, just the bulk if them. We have hundreds of thousands of lines of code, so a visual search would be inefficient use of people-time.
Thoughts or ideas?
Respectfully,
Ben
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
PMD might do if -- if it doesn't you can write a plugin that will.
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6035
I think JTest does it, although I think the tool is very expensive for a very poor interface. (I'm pretty sure they have a free trial license.) Look for tools which claim white-box testing or code analysis, these tools also tend to find things like dead branches, infinite loops, etc.
--Mark
saumil shukla
Ranch Hand

Joined: Dec 01, 2000
Posts: 47
"Discover" from MKS.COM is another tool which can help you browse relationships between objects as well.
Hope it helps.
Saumil
 
 
subject: Tool for finding "unused" objects?
 
Threads others viewed
Strong and weak reference.
how many String object have been created?
garbage collection
Garbage Collection - Practice
What is the use of Clone and Equal?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com