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

fix(subscriber): fix memory leak from historical PollOps #311

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions console-subscriber/src/aggregator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,10 @@ pub(crate) struct Aggregator {
/// Map of AsyncOp IDs to AsyncOp stats.
async_op_stats: IdData<Arc<stats::AsyncOpStats>>,

/// *All* PollOp events for AsyncOps on Resources.
///
/// This is sent to new clients as part of the initial state.
// TODO: drop the poll ops for async ops that have been dropped
all_poll_ops: ShrinkVec<proto::resources::PollOp>,

/// *New* PollOp events that whave occurred since the last update
/// `PollOp `events that have occurred since the last update
///
/// This is emptied on every state update.
new_poll_ops: Vec<proto::resources::PollOp>,
poll_ops: Vec<proto::resources::PollOp>,

/// The time "state" of the aggregator, such as paused or live.
temporality: Temporality,
Expand Down Expand Up @@ -157,8 +151,7 @@ impl Aggregator {
resource_stats: IdData::default(),
async_ops: IdData::default(),
async_op_stats: IdData::default(),
all_poll_ops: Default::default(),
new_poll_ops: Default::default(),
poll_ops: Default::default(),
temporality: Temporality::Live,
base_time,
}
Expand Down Expand Up @@ -292,8 +285,8 @@ impl Aggregator {

fn resource_update(&mut self, include: Include) -> proto::resources::ResourceUpdate {
let new_poll_ops = match include {
Include::All => (*self.all_poll_ops).clone(),
Include::UpdatedOnly => std::mem::take(&mut self.new_poll_ops),
Include::All => self.poll_ops.clone(),
Include::UpdatedOnly => std::mem::take(&mut self.poll_ops),
};
proto::resources::ResourceUpdate {
new_resources: self.resources.as_proto_list(include, &self.base_time),
Expand Down Expand Up @@ -465,8 +458,7 @@ impl Aggregator {
is_ready,
};

self.all_poll_ops.push(poll_op.clone());
self.new_poll_ops.push(poll_op);
self.poll_ops.push(poll_op);
}

Event::AsyncResourceOp {
Expand Down