Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in long running stream related to ConcurrentAsyncCallback's #24046

Closed
maxcom opened this issue Nov 22, 2017 · 7 comments
Closed

Memory leak in long running stream related to ConcurrentAsyncCallback's #24046

maxcom opened this issue Nov 22, 2017 · 7 comments
Assignees
Labels
3 - in progress Someone is working on this ticket bug t:stream
Milestone

Comments

@maxcom
Copy link

maxcom commented Nov 22, 2017

We have a long running stream that works fine in Akka 2.5.6. After update to 2.5.7, process runs out of memory after 5-10 minutes of processing. I see large number (~35000) of
GraphStageLogic.ConcurrentAsyncCallback instances in heap dump. Each of them holds a reference to some data objects that was processed in past.

I do not have a clean reproducer yet.

Here is screenshot from Eclipse Memory Analyzer:

2017-11-22 21 35 29

and one more:

2017-11-22 21 37 29

@patriknw
Copy link
Member

@maxcon Thanks for reporting, it looks like a serious regression. The async callbacks were changed in 2.5.7. A reproducer would be great.

@maxcom
Copy link
Author

maxcom commented Nov 23, 2017

Here is the reproducer: https://github.com/maxcom/akka-streams-oom.

Process runs fine for at least 10 minutes on Akka 2.5.6, and runs of of memory on first minute in 2.5.7.

@patriknw
Copy link
Member

Thanks!

@2m
Copy link
Member

2m commented Nov 23, 2017

With the new async callbacks we have started to store async callbacks in asyncCallbacksInProgress of the GraphStageLogic until graph stage is stopped.

Unfortunately streams of streams are implemented by using async callbacks, which never get released and thus OOM.

@johanandren
Copy link
Member

To be more concrete, the issue here is akka.stream.stage.GraphStageLogic.SubSinkInlet which triggers the creation of one of those callbacks here:

private val _sink = new SubSink[T](name, getAsyncCallback[ActorSubscriberMessage] { msg

For FlattenMerge one is created per sub stream that is materialized, but as there is no way to signal that the AsyncCallback should be released/not kept around anymore when the sub sink has completed/canceled it stays in memory.

Problem is probably there for the opposite as well (SubSourceOutlet)

@t3hnar
Copy link
Contributor

t3hnar commented Nov 27, 2017

Hi guys, any estimate on fix?

@patriknw
Copy link
Member

We will take a deep look at this tomorrow.

@patriknw patriknw added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding bug t:stream labels Nov 27, 2017
@johanandren johanandren self-assigned this Nov 28, 2017
@johanandren johanandren added 3 - in progress Someone is working on this ticket and removed 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding labels Nov 28, 2017
johanandren added a commit to johanandren/akka that referenced this issue Nov 28, 2017
johanandren added a commit to johanandren/akka that referenced this issue Nov 28, 2017
johanandren added a commit that referenced this issue Dec 5, 2017
@johanandren johanandren added this to the 2.5.8 milestone Dec 5, 2017
manonthegithub pushed a commit to manonthegithub/akka that referenced this issue Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - in progress Someone is working on this ticket bug t:stream
Projects
None yet
Development

No branches or pull requests

5 participants