In Java can making a local variable final in a non-static method that is called many times cause a memory leak? -


for example lets have:

    public void dothis() {         final foo foo = foo.getinstance();         ... initialize foo somehow...         baz(bar.getinstance(foo)); // adds bar instance         ... bar popped list, used, , disposed of...     } 

can memory leak occur scenario?

i'm not understanding final local variable means. mean local variable cannot reassigned, , it? declaring final put somewhere in java heap/memory such it's instance variable different/unique? since inner/nested class can use final local variable, not non-final local variable?

no. if there wasn't memory leak without final, there won't 1 final.

the only thing final local variable (in java 8)1 prevent assigning variable more once.

1 in java 7 , earlier, there effect had nothing memory leaks.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -