In the methods, do I need to set variables to null before leaving? or those variables are automatically discarded and the corresponding referenced objects will be garbage collected?
Originally posted by Yasir Qureshi:
What I think is that b4 reaching line Boom the variable tmp goes out of scope and the object to which it points is also availible for GC, it makes 11.
AM I RIGHT?
Originally posted by Alex Guo:
I am wondering what I shall do if I want to collect garbage on time so that the application won't run out of memory. I think it's very important for a software product to sustain stress test.
In the methods, do I need to set variables to null before leaving? or those variables are automatically discarded and the corresponding referenced objects will be garbage collected(later)? Is there any other thing I shall do for this?
A new frame is created each time a Java method is invoked. A frame is destroyed when its method completes, whether that completion is normal or abnormal (by throwing an exception). Frames are allocated from the Java stack (�3.5.2) of the thread creating the frame. Each frame has its own set of local variables (�3.6.1) and its own operand stack (�3.6.2).
The local variable effectively ceases to exist when the execution of the block or for statement is complete.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton