Skip to content

3.x: ReplayProcessor retains unused object #7417

Closed
@ansip

Description

@ansip

Hi,

I've encountered the issue using ReplayProcessor
The problem is that it keeps previous published object, in my case this object is about 600MB

I'm aware of javadoc and cleanupBuffer method

  • Note that due to concurrency requirements, a size- and time-bounded {@code ReplayProcessor} may hold strong references to more
  • source emissions than specified while it isn't terminated yet. Use the {@link #cleanupBuffer()} to allow
  • such inaccessible items to be cleaned up by GC once no consumer references them anymore.

but this api looks a bit tricky and inconvinient especially if you work with processor via abstract class for example FlowableProcessor

I think we could get rid from cleanupBuffer and trimHead if we change algorithm a bit
Basically the idea is to make Node/TimedNode mutable and fill values in node which is pointed by tail, then shift tail to a new empty node, hence trim method will remove head with relevant data when conditions met

If you don't mind I can raise a PR, and there we can discuss more specifically

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions