GC does not fire as soon as you call System.gc() - this just requests it. Please, put Thread.sleep(100); here in order to give the GC a chance (see java.nio.Bits.reserveMemory() for reference).