A little question regarding performance in a Java web app.
Let\'s assume I have a List
listRubriques
with ten Rubriqu
"Pretty soon" is a rather vague specification, but the garbage collector is probably not as swift as you seem to expect. When the objects actually will be collected depends a lot on the GC configuration and your server load, but it may take some time and if your VM has enough heap available and other things to do, the objects won't be collected "pretty soon".
The only situation where the VM specification guarantees that the GC will run, is when at some point otherwise an OutOfMemoryError would be thrown. Before throwing an OutOfMemoryError, the VM is obligated to make an attempt to at least collect so many eligible object instances, that the relevant memory allocation request can succeed (but you're still not guaranteed that all eligible instances are collected).