Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tool for finding "unused" objects?  RSS feed

 
Ben Ethridge
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PMD might do if -- if it doesn't you can write a plugin that will.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Discover" from MKS.COM is another tool which can help you browse relationships between objects as well.
Hope it helps.
Saumil
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!