Skip to content

Commit

Permalink
Fix memory leak when temporal RDO not in use
Browse files Browse the repository at this point in the history
The cached intra costs ended up using a non-trivial amount of memory, so
we need to ensure they are not kept around when they are not needed.
In the case of temporal RDO, these are already removed from the cache
when we move them into the FrameInvariants.
  • Loading branch information
shssoichiro committed Mar 15, 2022
1 parent 7164b92 commit de97f3b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/scenechange/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ impl<T: Pixel> SceneChangeDetector<T> {
intra_cost = intra_costs.iter().map(|&cost| cost as u64).sum::<u64>()
as f64
/ intra_costs.len() as f64;
// If we're not using temporal RDO, we won't need these costs later,
// so remove them from the cache to avoid a memory leak
if !self.encoder_config.temporal_rdo() {
self.intra_costs.remove(&input_frameno);
};
});
s.spawn(|_| {
mv_inter_cost = estimate_inter_costs(
Expand Down

0 comments on commit de97f3b

Please sign in to comment.