When adding documents to a window, we update the stats only after all documents have been added.
When restoring from a window, we update the stats only after all the documents have been added.
If a window has many documents, then we can run into an OOM in the middle of these operations. Try to update the stats in a more fine grained way.