From 3badd42d15a7da3371541f99b601911e6e15ddc2 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 23 Jun 2021 12:00:56 +0100 Subject: [PATCH] nonempty 0.7 We can now correctly measure the heap-allocated memory used by a bundle. --- Cargo.toml | 2 +- src/bundle.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 03ae2063..8c3e796e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ lazy_static = "1" pasta_curves = "0.1" proptest = { version = "1.0.0", optional = true } rand = "0.8" -nonempty = "0.6" +nonempty = "0.7" serde = { version = "1.0", features = ["derive"] } subtle = "2.3" zcash_note_encryption = "0.0" diff --git a/src/bundle.rs b/src/bundle.rs index 5b484191..6c10fdf3 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -360,9 +360,7 @@ impl Bundle { /// Returns the amount of heap-allocated memory used by this bundle. pub fn dynamic_usage(&self) -> usize { // NonEmpty stores its head element separately from its tail Vec. - // TODO: This underestimates the dynamic usage; switch to NonEmpty::capacity once - // https://github.com/cloudhead/nonempty/issues/33 is closed. - (self.actions.len() - 1) * mem::size_of::>>() + (self.actions.capacity() - 1) * mem::size_of::>>() + self.authorization.proof.dynamic_usage() }