Skip to content

Commit

Permalink
fix: don't leak memory (#150)
Browse files Browse the repository at this point in the history
Turns out the hugr priority queue never dropped the old circuits in
`truncate`.

Now the memory usage remains ~constant once the queue reaches its
maximum size.
  • Loading branch information
aborgna-q authored Sep 29, 2023
1 parent ca2d3df commit 0e9540b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/optimiser/taso/hugr_pqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ impl<P: Ord, C> HugrPQ<P, C> {
/// Only keep up to `max_size` elements.
pub(super) fn truncate(&mut self, max_size: usize) {
while self.queue.len() > max_size {
self.queue.pop_max();
let (hash, _) = self.queue.pop_max().unwrap();
self.hash_lookup.remove(&hash);
}
}

Expand Down

0 comments on commit 0e9540b

Please sign in to comment.