It is only given the opportunity to collect when you allocate (new/more) memory. It can decide not to, or to do so at any point making it very unpredictable.
This is why we keep saying that it is not a magic bullet. It isn't. It just does a simple set of logic and nothing more.