I went through the following link on oracle official site regarding performance tuning, which states "Assigning null to unused variable ease garbage collector to reclaim the memory"
Do I need to adopt the following code practice?
Student student = new Student(100L, "Brian Lara", "II", "B");
public String getSomeValue() {
String val = "";
try {
// Perform some action to get value using student ref. variable
// val = some val, using student
}
finally {
this.student = null;
}
return val;
}
- There are 3 possibilities (or may be more) for the instance variable:
- Global static instance variable
- Global non static instance variable
- Local non static instance variable
Please suggest the correct way for the better coding practice.