Use estimateSize instead of atGrowThreshold to test collection sizes

The previous code used atGrowThreshold, which is only true when the
collection is about to double. Unfortunately, by that time, we could've
already inserted a lot more stuff than our previous limit.

I also modified it to check only every 32 elements since estimateSize is
a bit more expensive than atGrowThreshold, and to choose a new memory
limit that is at least 2x bigger than the current size.