Paul,
Garbage collection is a lower priority activity for the JVM. Hence, even if you invoke System.gc(), it doesn't guarantee garbage collection instantly. You can configure JVM parameters to do more efficient garbage collection. Please note that too frequent GC is also not good as it will result in higher resource usage (like CPU) and can inversely affect the performance.