Skip to content

Commit

Permalink
Different reporting of leaked sets
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed Apr 29, 2021
1 parent 5cc21e0 commit 0015c1a
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions gpu-descriptor/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,33 @@ struct DescriptorBucket<P> {
}

impl<P> Drop for DescriptorBucket<P> {
#[cfg(feature = "tracing")]
fn drop(&mut self) {
#[cfg(feature = "std")]
if !std::thread::panicking() {
assert_eq!(
self.total, 0,
"Allocator dropped before all sets were deallocated"
);
{
if std::thread::panicking() {
return;
}
}
if self.total > 0 {
tracing::error!("Descriptor sets were not deallocated");
}
}

assert!(
self.pools.is_empty(),
"All sets deallocated but pools were not. Make sure to call `Allocator::cleanup`"
);
#[cfg(all(not(feature = "tracing"), feature = "std"))]
fn drop(&mut self) {
if std::thread::panicking() {
return;
}
if self.total > 0 {
eprintln!("Descriptor sets were not deallocated")
}
}

#[cfg(all(not(feature = "tracing"), not(feature = "std")))]
fn drop(&mut self) {
if self.total > 0 {
panic!("Descriptor sets were not deallocated")
}
}
}
Expand Down

0 comments on commit 0015c1a

Please sign in to comment.