byte[] largeByteArray = new byte[1000000000]; //1GB byte array
largeByteArray = null;
Will setting largeByteArray
to null
free the 1GB memory immediately or do we have to wait for garbage collector to release the 1GB?
If the answer is "we have to wait for GC" then is there any benefit of setting largeByteArray
to null
? Does it help the JVM somehow?