This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalize() method

 
Devu Shah
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have one doubt.
I am using VERY BIG Help file in JEditorPane ( to show online help) as follow.
URL url = ClassLoader.getSystemResource(fileName);
pane = new JEditorPane(url);
..................
.................
Now what should I make null, in finalize method, to free up non java resource ?
should it be url ?
or pane ?
i.e. should it be url = null;
or pane = null; in finalize method.
thanks in advance.
Devu
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If url is a class member, you should set both to null. If it's a local reference that goes away on the completion of its enclosing method, it would seem like setting pane to null is sufficient.
There's no significant cost in dong both when you're not sure, though.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic