=str #16986 Fix memory leak in PrefixAndTail when using Sink.publisher

The problem was reproduced with the TCK PrefixAndTailTest
required_spec313_cancelMustMakeThePublisherEventuallyDropAllReferencesToTheSubscriber
The tck subscriber was still referenced. Profiling revealed that the
root cause was the VirtualPublisher that holds a reference to the
realPublisher, which was MultiStreamOutputProcessor$SubstreamOutput,
which had the reference to the subscriber. The VirtualPublisher
is created by the Sink.publisher in the test, and the test holds
on to that VirtualPublisher reference.

The solution is to null out realPublisher field in the VirtualPublisher.

The old workaround with the NullSubscriber was removed.

Also made Sink.publisher reject additional subscribers.
This commit is contained in:
Patrik Nordwall 2015-04-16 16:05:49 +02:00
parent 050c0549f3
commit 2a975bfb35
7 changed files with 32 additions and 38 deletions

View file

@ -68,7 +68,6 @@ private[akka] object MultiStreamOutputProcessor {
override def cancel(): Unit = {
if (!downstreamCompleted) {
closePublisher(Cancelled)
subscriber = NullSubscriber // FIXME unreference real subscriber, should not be needed after #16986
downstreamCompleted = true
}
}