Which would clear up memory quicker:
Given we have a linked list, in this case ArrayList, but feel free to explain this for other lists:
ArrayList<String> list = ...10000 elements
Either A)
list.clear();
System.gc();
Or B)
list = null;
System.gc();
No, it won’t free up the memory immediately. You can’t do that.
The memory will be freed as soon as the garbage collector runs. But you can’t force it running. You can merely suggest to the JVM that the garbage collector should be run, but it is by no means forced to do so.