I have a try catch and finally block like this.
Client client = new Client();
try {
...
}
catch {
...
}
finally {
client = null;
}
I would like to ask if client = null is necessary to wipe out memory use for client object if exception occurs.
Whenever an object has no references to it for any reason then it becomes eligible for garbage collection, including if a variable goes out of scope as a result of the program leaving a function or statement block. In other words, no.