Details
Description
The ReplicateContext object is created once per ReplicationSource and then reused when we have something to ship to the sinks.
This is a misguided optimization. ReplicateContext is very lightweight (definitely compared to the all the work and copying the ReplicationSource is doing) and, crucially, it prevent the the entries array from being collected after it was successfully copied to the sink, wasting potentially a lot of heap.
The entries array itself holds reference to WAL entries on the heap, that now also cannot be collected.