Free memory of a byte array in Java
When creating a new byte[] in Java, you do something like
byte[] myArray = new byte[54];
To free it, you should do
myArray = null;
If something else references your byte array, like
yourArray = myArray;
you need to also set the other references to null, like so
yourArray = null;
In Java garbage collection is automatic. If the JVM can detect that a piece of memory is no longer reachable by the entire program, then the JVM will free the memory for you.