Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>It is not calling finalize(). Is it memory leak?</p> </blockquote> <p>Finalize is not guaranteed to be called, it is called when the garbage collector collects the given object but the objects are not guaranteed to be collected before the execution ends.</p> <blockquote> <p>There is not change in free memory up to N=1000. But when N=1500 there is 2 different values >for used memory at the end of the program ie 282K and 370K. Why does it so?</p> </blockquote> <p>I think it depends on the execution of the garbage collector and the moments that it gets executed. </p> <blockquote> <p>When N=6500, JVM generates error. So why last 2 statements of try{} are executed.</p> </blockquote> <p>This is because you're not catching the exception since <code>StackOverflowError</code> inherits from <code>Error</code> that is not part of the Exception inheritance branch but rather is a brother of <code>Exception</code>, anyway you have no code in the catch, the last two methods of your try are not being executed because the exception has been thrown.</p> <p>In summary you didn't produce a memory leak, memory leaks happen in java when you have references to objects that are reachable (directly or indirectly) from the execution flow at some point, for example you store objects in a collection that you can reach, or singletons.</p> <p>The garbage collector itself is smart enough to free object graphs that are not reachable from the program at all.</p> <p>Hope I could make it clear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload