What you say makes sense, but probably the net result is unpredictable. Suppose, for example, that there is some heap space left before calling makeIndex(), and that makeIndex() itself creates a fair amount of garbage. In that case, postponing the garbage collection might still win.
It might be interesting for you to try it both ways and see what works better. |