diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock
index 736501ecefd7945e956cb914fa0858594f96b0f2..1ba2462a24caad7d74858faa1a6b9990f40ed67b 100644
--- a/substrate/Cargo.lock
+++ b/substrate/Cargo.lock
@@ -2241,7 +2241,6 @@ dependencies = [
  "log",
  "once_cell",
  "parity-scale-codec",
- "parity-util-mem",
  "paste",
  "pretty_assertions",
  "scale-info",
@@ -3378,35 +3377,31 @@ dependencies = [
 
 [[package]]
 name = "kvdb"
-version = "0.12.0"
+version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "585089ceadba0197ffe9af6740ab350b325e3c1f5fccfbc3522e0250c750409b"
+checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9"
 dependencies = [
- "parity-util-mem",
  "smallvec",
 ]
 
 [[package]]
 name = "kvdb-memorydb"
-version = "0.12.0"
+version = "0.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "40d109c87bfb7759edd2a49b2649c1afe25af785d930ad6a38479b4dc70dd873"
+checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2"
 dependencies = [
  "kvdb",
- "parity-util-mem",
  "parking_lot 0.12.1",
 ]
 
 [[package]]
 name = "kvdb-rocksdb"
-version = "0.16.0"
+version = "0.17.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c076cc2cdbac89b9910c853a36c957d3862a779f31c2661174222cefb49ee597"
+checksum = "2182b8219fee6bd83aacaab7344e840179ae079d5216aa4e249b4d704646a844"
 dependencies = [
  "kvdb",
- "log",
  "num_cpus",
- "parity-util-mem",
  "parking_lot 0.12.1",
  "regex",
  "rocksdb",
@@ -4081,13 +4076,12 @@ dependencies = [
 
 [[package]]
 name = "memory-db"
-version = "0.30.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34ac11bb793c28fa095b7554466f53b3a60a2cd002afdac01bcf135cbd73a269"
+checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66"
 dependencies = [
  "hash-db",
  "hashbrown 0.12.3",
- "parity-util-mem",
 ]
 
 [[package]]
@@ -4433,7 +4427,6 @@ dependencies = [
  "node-primitives",
  "node-testing",
  "parity-db",
- "parity-util-mem",
  "rand 0.7.3",
  "sc-basic-authorship",
  "sc-client-api",
@@ -4527,7 +4520,6 @@ dependencies = [
  "sp-tracing",
  "sp-transaction-pool",
  "sp-transaction-storage-proof",
- "sp-trie",
  "substrate-build-script-utils",
  "substrate-frame-cli",
  "substrate-rpc-client",
@@ -6379,33 +6371,6 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
 
-[[package]]
-name = "parity-util-mem"
-version = "0.12.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8"
-dependencies = [
- "cfg-if",
- "hashbrown 0.12.3",
- "impl-trait-for-tuples",
- "parity-util-mem-derive",
- "parking_lot 0.12.1",
- "primitive-types",
- "smallvec",
- "winapi",
-]
-
-[[package]]
-name = "parity-util-mem-derive"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2"
-dependencies = [
- "proc-macro2",
- "syn",
- "synstructure",
-]
-
 [[package]]
 name = "parity-wasm"
 version = "0.45.0"
@@ -8066,7 +8031,6 @@ dependencies = [
  "futures",
  "futures-timer",
  "log",
- "parity-util-mem",
  "sc-client-api",
  "sc-network-common",
  "sc-transaction-pool-api",
@@ -8498,7 +8462,6 @@ dependencies = [
  "jsonrpsee",
  "log",
  "parity-scale-codec",
- "parity-util-mem",
  "parking_lot 0.12.1",
  "pin-project",
  "rand 0.7.3",
@@ -8600,8 +8563,6 @@ version = "0.10.0-dev"
 dependencies = [
  "log",
  "parity-scale-codec",
- "parity-util-mem",
- "parity-util-mem-derive",
  "parking_lot 0.12.1",
  "sc-client-api",
  "sp-core",
@@ -8715,7 +8676,6 @@ dependencies = [
  "linked-hash-map",
  "log",
  "parity-scale-codec",
- "parity-util-mem",
  "parking_lot 0.12.1",
  "sc-block-builder",
  "sc-client-api",
@@ -9723,7 +9683,6 @@ dependencies = [
  "impl-trait-for-tuples",
  "log",
  "parity-scale-codec",
- "parity-util-mem",
  "paste",
  "rand 0.7.3",
  "scale-info",
@@ -9908,7 +9867,6 @@ name = "sp-test-primitives"
 version = "2.0.0"
 dependencies = [
  "parity-scale-codec",
- "parity-util-mem",
  "serde",
  "sp-application-crypto",
  "sp-core",
@@ -10333,7 +10291,6 @@ dependencies = [
  "pallet-babe",
  "pallet-timestamp",
  "parity-scale-codec",
- "parity-util-mem",
  "sc-block-builder",
  "sc-executor",
  "sc-service",
@@ -10850,9 +10807,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
 
 [[package]]
 name = "trie-bench"
-version = "0.32.0"
+version = "0.33.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0dae77b1daad50cd3ed94c506d2dab27e2e47f7b5153a6d4b1992bb3f6028cb"
+checksum = "c5b26bd2cdd7641c5beb476b314c0cb1f629832bf21a6235f545e2d47bc9d05a"
 dependencies = [
  "criterion",
  "hash-db",
diff --git a/substrate/bin/node/bench/Cargo.toml b/substrate/bin/node/bench/Cargo.toml
index 33c9e7c89268f9c53f3b9061ad1b603b787ecdcf..63087215ae1926dc2ca5c15941e8ed35b5246e6b 100644
--- a/substrate/bin/node/bench/Cargo.toml
+++ b/substrate/bin/node/bench/Cargo.toml
@@ -23,8 +23,8 @@ sp-state-machine = { version = "0.13.0", path = "../../../primitives/state-machi
 serde = "1.0.136"
 serde_json = "1.0.85"
 derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
-kvdb = "0.12.0"
-kvdb-rocksdb = "0.16.0"
+kvdb = "0.13.0"
+kvdb-rocksdb = "0.17.0"
 sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
 sp-core = { version = "7.0.0", path = "../../../primitives/core" }
 sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
@@ -37,7 +37,6 @@ tempfile = "3.1.0"
 fs_extra = "1"
 rand = { version = "0.7.2", features = ["small_rng"] }
 lazy_static = "1.4.0"
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 parity-db = "0.4.2"
 sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
 sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
diff --git a/substrate/bin/node/bench/src/tempdb.rs b/substrate/bin/node/bench/src/tempdb.rs
index eb3bb1d3fccd7db429eec8866a38cd96c75a131b..82895ddfab69d46e5d9ad37240120c24ba954fba 100644
--- a/substrate/bin/node/bench/src/tempdb.rs
+++ b/substrate/bin/node/bench/src/tempdb.rs
@@ -29,7 +29,6 @@ pub enum DatabaseType {
 pub struct TempDatabase(tempfile::TempDir);
 
 struct ParityDbWrapper(parity_db::Db);
-parity_util_mem::malloc_size_of_is_0!(ParityDbWrapper);
 
 impl KeyValueDB for ParityDbWrapper {
 	/// Get a value by key.
diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml
index 108923265fb1f8aceb7bc604b2e3ab972da8f8d4..cb2baf9e0de304a6bd7248dd108525905a28e258 100644
--- a/substrate/bin/node/cli/Cargo.toml
+++ b/substrate/bin/node/cli/Cargo.toml
@@ -101,11 +101,6 @@ node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" }
 try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" }
 serde_json = "1.0.85"
 
-[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
-sp-trie = { version = "7.0.0", default-features = false, path = "../../../primitives/trie", features = [
-	"memory-tracker",
-] }
-
 [dev-dependencies]
 sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
 sc-client-db = { version = "0.10.0-dev", path = "../../../client/db" }
diff --git a/substrate/client/api/src/client.rs b/substrate/client/api/src/client.rs
index bb88853d23afb44c2f200410283e59a7f91cbd81..05e3163dcc7bd664e4ec981eddddd3a0f9ca79b1 100644
--- a/substrate/client/api/src/client.rs
+++ b/substrate/client/api/src/client.rs
@@ -197,17 +197,6 @@ impl fmt::Display for MemorySize {
 	}
 }
 
-/// Memory statistics for state db.
-#[derive(Default, Clone, Debug)]
-pub struct StateDbMemoryInfo {
-	/// Memory usage of the non-canonical overlay
-	pub non_canonical: MemorySize,
-	/// Memory usage of the pruning window.
-	pub pruning: Option<MemorySize>,
-	/// Memory usage of the pinned blocks.
-	pub pinned: MemorySize,
-}
-
 /// Memory statistics for client instance.
 #[derive(Default, Clone, Debug)]
 pub struct MemoryInfo {
@@ -215,8 +204,6 @@ pub struct MemoryInfo {
 	pub state_cache: MemorySize,
 	/// Size of backend database cache.
 	pub database_cache: MemorySize,
-	/// Size of the state db.
-	pub state_db: StateDbMemoryInfo,
 }
 
 /// I/O statistics for client instance.
@@ -264,13 +251,9 @@ impl fmt::Display for UsageInfo {
 		write!(
 			f,
 			"caches: ({} state, {} db overlay), \
-			 state db: ({} non-canonical, {} pruning, {} pinned), \
 			 i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} trie nodes writes)",
 			self.memory.state_cache,
 			self.memory.database_cache,
-			self.memory.state_db.non_canonical,
-			self.memory.state_db.pruning.unwrap_or_default(),
-			self.memory.state_db.pinned,
 			self.io.transactions,
 			self.io.bytes_written,
 			self.io.bytes_read,
diff --git a/substrate/client/db/Cargo.toml b/substrate/client/db/Cargo.toml
index dda1a640d886f52c09b2187f4a99b869072d6438..ee879a161edfe4c887e0f398a954ddbb45b65624 100644
--- a/substrate/client/db/Cargo.toml
+++ b/substrate/client/db/Cargo.toml
@@ -17,9 +17,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
 	"derive",
 ] }
 hash-db = "0.15.2"
-kvdb = "0.12.0"
-kvdb-memorydb = "0.12.0"
-kvdb-rocksdb = { version = "0.16.0", optional = true }
+kvdb = "0.13.0"
+kvdb-memorydb = "0.13.0"
+kvdb-rocksdb = { version = "0.17.0", optional = true }
 linked-hash-map = "0.5.4"
 log = "0.4.17"
 parity-db = "0.4.2"
@@ -36,7 +36,7 @@ sp-trie = { version = "7.0.0", path = "../../primitives/trie" }
 
 [dev-dependencies]
 criterion = "0.3.3"
-kvdb-rocksdb = "0.16.0"
+kvdb-rocksdb = "0.17.0"
 rand = "0.8.4"
 tempfile = "3.1.0"
 quickcheck = { version = "1.0.3", default-features = false }
diff --git a/substrate/client/db/src/lib.rs b/substrate/client/db/src/lib.rs
index 305db2284b2ed42713f997c497d96095ae0e5484..426876f5cba8c578f161ad87cff819d1499340d7 100644
--- a/substrate/client/db/src/lib.rs
+++ b/substrate/client/db/src/lib.rs
@@ -2086,10 +2086,9 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
 		let state_cache = MemorySize::from_bytes(
 			self.shared_trie_cache.as_ref().map_or(0, |c| c.used_memory_size()),
 		);
-		let state_db = self.storage.state_db.memory_info();
 
 		Some(UsageInfo {
-			memory: MemoryInfo { state_cache, database_cache, state_db },
+			memory: MemoryInfo { state_cache, database_cache },
 			io: IoInfo {
 				transactions: io_stats.transactions,
 				bytes_read: io_stats.bytes_read,
diff --git a/substrate/client/db/src/storage_cache.rs b/substrate/client/db/src/storage_cache.rs
index d9253fe09eb50375292af27d28b21b5cf547ea1d..474599e5d74e87ec2c140cc246ef33e48719e848 100644
--- a/substrate/client/db/src/storage_cache.rs
+++ b/substrate/client/db/src/storage_cache.rs
@@ -59,15 +59,11 @@ pub struct Cache<B: BlockT> {
 
 struct LRUMap<K, V>(LinkedHashMap<K, V>, usize, usize);
 
-/// Internal trait similar to `heapsize` but using
-/// a simply estimation.
+/// Internal trait similar to `heapsize` but using a simple estimation.
 ///
-/// This should not be made public, it is implementation
-/// detail trait. If it need to become public please
-/// consider using `malloc_size_of`.
+/// This should not be made public, it is an implementation detail trait.
 trait EstimateSize {
-	/// Return a size estimation of additional size needed
-	/// to cache this struct (in bytes).
+	/// Return a size estimation of the additional size needed to cache this struct (in bytes).
 	fn estimate_size(&self) -> usize;
 }
 
diff --git a/substrate/client/informant/Cargo.toml b/substrate/client/informant/Cargo.toml
index 682a754ba16a651d1711415c5f0edfe61bd01c90..a432c2ada5c617295a2cd45b725954c5ade93011 100644
--- a/substrate/client/informant/Cargo.toml
+++ b/substrate/client/informant/Cargo.toml
@@ -17,7 +17,6 @@ ansi_term = "0.12.1"
 futures = "0.3.21"
 futures-timer = "3.0.1"
 log = "0.4.17"
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 sc-client-api = { version = "4.0.0-dev", path = "../api" }
 sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
 sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
diff --git a/substrate/client/informant/src/lib.rs b/substrate/client/informant/src/lib.rs
index 52f1c95fe019816be999d6eb844d082636c4dbf2..b03b92686e2aac833d3878affb15ee690572aa59 100644
--- a/substrate/client/informant/src/lib.rs
+++ b/substrate/client/informant/src/lib.rs
@@ -22,10 +22,8 @@ use ansi_term::Colour;
 use futures::prelude::*;
 use futures_timer::Delay;
 use log::{debug, info, trace};
-use parity_util_mem::MallocSizeOf;
 use sc_client_api::{BlockchainEvents, UsageProvider};
 use sc_network_common::service::NetworkStatusProvider;
-use sc_transaction_pool_api::TransactionPool;
 use sp_blockchain::HeaderMetadata;
 use sp_runtime::traits::{Block as BlockT, Header};
 use std::{collections::VecDeque, fmt::Display, sync::Arc, time::Duration};
@@ -53,16 +51,11 @@ impl Default for OutputFormat {
 }
 
 /// Builds the informant and returns a `Future` that drives the informant.
-pub async fn build<B: BlockT, C, N, P>(
-	client: Arc<C>,
-	network: N,
-	pool: Arc<P>,
-	format: OutputFormat,
-) where
+pub async fn build<B: BlockT, C, N>(client: Arc<C>, network: N, format: OutputFormat)
+where
 	N: NetworkStatusProvider<B>,
 	C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
 	<C as HeaderMetadata<B>>::Error: Display,
-	P: TransactionPool + MallocSizeOf,
 {
 	let mut display = display::InformantDisplay::new(format.clone());
 
@@ -83,11 +76,6 @@ pub async fn build<B: BlockT, C, N, P>(
 					"Usage statistics not displayed as backend does not provide it",
 				)
 			}
-			trace!(
-				target: "usage",
-				"Subsystems memory [txpool: {} kB]",
-				parity_util_mem::malloc_size(&*pool) / 1024,
-			);
 			display.display(&info, net_status);
 			future::ready(())
 		});
diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml
index 8b17a8287c27447ba360bfede01de96d5d9eaf09..87949ef12d888e89b25f933563ad82a06d96dcc6 100644
--- a/substrate/client/service/Cargo.toml
+++ b/substrate/client/service/Cargo.toml
@@ -80,9 +80,6 @@ sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
 sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
 tracing = "0.1.29"
 tracing-futures = { version = "0.2.4" }
-parity-util-mem = { version = "0.12.0", default-features = false, features = [
-	"primitive-types",
-] }
 async-trait = "0.1.57"
 tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
 tempfile = "3.1.0"
diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs
index df20f2009ee095f6d761f628737b35462650563d..dd89ce6dff10afca3b96c235db08c72114065e44 100644
--- a/substrate/client/service/src/builder.rs
+++ b/substrate/client/service/src/builder.rs
@@ -436,9 +436,7 @@ where
 	TBl::Hash: Unpin,
 	TBl::Header: Unpin,
 	TBackend: 'static + sc_client_api::backend::Backend<TBl> + Send,
-	TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash>
-		+ parity_util_mem::MallocSizeOf
-		+ 'static,
+	TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash> + 'static,
 {
 	let SpawnTasksParams {
 		mut config,
@@ -540,12 +538,7 @@ where
 	spawn_handle.spawn(
 		"informant",
 		None,
-		sc_informant::build(
-			client.clone(),
-			network,
-			transaction_pool.clone(),
-			config.informant_output_format,
-		),
+		sc_informant::build(client.clone(), network, config.informant_output_format),
 	);
 
 	task_manager.keep_alive((config.base_path, rpc));
diff --git a/substrate/client/service/src/metrics.rs b/substrate/client/service/src/metrics.rs
index 13b249a7b95638275345fd9c340b96e1868b66fd..c83b3988f9fa3b5caa50c417dd0398f6b6cb7731 100644
--- a/substrate/client/service/src/metrics.rs
+++ b/substrate/client/service/src/metrics.rs
@@ -43,7 +43,6 @@ struct PrometheusMetrics {
 	// I/O
 	database_cache: Gauge<U64>,
 	state_cache: Gauge<U64>,
-	state_db: GaugeVec<U64>,
 }
 
 impl PrometheusMetrics {
@@ -117,13 +116,6 @@ impl PrometheusMetrics {
 				Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
 				registry,
 			)?,
-			state_db: register(
-				GaugeVec::new(
-					Opts::new("substrate_state_db_cache_bytes", "State DB cache in bytes"),
-					&["subtype"],
-				)?,
-				registry,
-			)?,
 		})
 	}
 }
@@ -254,18 +246,6 @@ impl MetricsService {
 			if let Some(info) = info.usage.as_ref() {
 				metrics.database_cache.set(info.memory.database_cache.as_bytes() as u64);
 				metrics.state_cache.set(info.memory.state_cache.as_bytes() as u64);
-
-				metrics
-					.state_db
-					.with_label_values(&["non_canonical"])
-					.set(info.memory.state_db.non_canonical.as_bytes() as u64);
-				if let Some(pruning) = info.memory.state_db.pruning {
-					metrics.state_db.with_label_values(&["pruning"]).set(pruning.as_bytes() as u64);
-				}
-				metrics
-					.state_db
-					.with_label_values(&["pinned"])
-					.set(info.memory.state_db.pinned.as_bytes() as u64);
 			}
 		}
 
diff --git a/substrate/client/state-db/Cargo.toml b/substrate/client/state-db/Cargo.toml
index 07c08363287d69b18b125fab4b7bc9297fd18180..b6d40a81063228819c0733c978f3cd63267e4c52 100644
--- a/substrate/client/state-db/Cargo.toml
+++ b/substrate/client/state-db/Cargo.toml
@@ -15,8 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"]
 [dependencies]
 codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
 log = "0.4.17"
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
-parity-util-mem-derive = "0.1.0"
 parking_lot = "0.12.1"
 sc-client-api = { version = "4.0.0-dev", path = "../api" }
 sp-core = { version = "7.0.0", path = "../../primitives/core" }
diff --git a/substrate/client/state-db/src/lib.rs b/substrate/client/state-db/src/lib.rs
index 01a198a1b3c1e1a98e1814a761a2731a674860a6..94d41787701b32123675fecc9456b48afbe632e4 100644
--- a/substrate/client/state-db/src/lib.rs
+++ b/substrate/client/state-db/src/lib.rs
@@ -49,10 +49,8 @@ mod test;
 use codec::Codec;
 use log::trace;
 use noncanonical::NonCanonicalOverlay;
-use parity_util_mem::{malloc_size, MallocSizeOf};
 use parking_lot::RwLock;
 use pruning::{HaveBlock, RefWindow};
-use sc_client_api::{MemorySize, StateDbMemoryInfo};
 use std::{
 	collections::{hash_map::Entry, HashMap},
 	fmt,
@@ -220,8 +218,6 @@ pub struct Constraints {
 	/// Maximum blocks. Defaults to 0 when unspecified, effectively keeping only non-canonical
 	/// states.
 	pub max_blocks: Option<u32>,
-	/// Maximum memory in the pruning overlay.
-	pub max_mem: Option<usize>,
 }
 
 /// Pruning mode.
@@ -238,7 +234,7 @@ pub enum PruningMode {
 impl PruningMode {
 	/// Create a mode that keeps given number of blocks.
 	pub fn blocks_pruning(n: u32) -> PruningMode {
-		PruningMode::Constrained(Constraints { max_blocks: Some(n), max_mem: None })
+		PruningMode::Constrained(Constraints { max_blocks: Some(n) })
 	}
 
 	/// Is this an archive (either ArchiveAll or ArchiveCanonical) pruning mode?
@@ -276,7 +272,7 @@ impl Default for PruningMode {
 
 impl Default for Constraints {
 	fn default() -> Self {
-		Self { max_blocks: Some(DEFAULT_MAX_BLOCK_CONSTRAINT), max_mem: None }
+		Self { max_blocks: Some(DEFAULT_MAX_BLOCK_CONSTRAINT) }
 	}
 }
 
@@ -294,9 +290,7 @@ pub struct StateDbSync<BlockHash: Hash, Key: Hash, D: MetaDb> {
 	ref_counting: bool,
 }
 
-impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
-	StateDbSync<BlockHash, Key, D>
-{
+impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDbSync<BlockHash, Key, D> {
 	fn new(
 		mode: PruningMode,
 		ref_counting: bool,
@@ -306,8 +300,7 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
 
 		let non_canonical: NonCanonicalOverlay<BlockHash, Key> = NonCanonicalOverlay::new(&db)?;
 		let pruning: Option<RefWindow<BlockHash, Key, D>> = match mode {
-			PruningMode::Constrained(Constraints { max_mem: Some(_), .. }) => unimplemented!(),
-			PruningMode::Constrained(Constraints { max_blocks, .. }) =>
+			PruningMode::Constrained(Constraints { max_blocks }) =>
 				Some(RefWindow::new(db, max_blocks.unwrap_or(0), ref_counting)?),
 			PruningMode::ArchiveAll | PruningMode::ArchiveCanonical => None,
 		};
@@ -392,10 +385,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
 					break
 				}
 
-				if constraints.max_mem.map_or(false, |m| pruning.mem_used() > m) {
-					break
-				}
-
 				let pinned = &self.pinned;
 				match pruning.next_hash() {
 					// the block record is temporary unavailable, break and try next time
@@ -496,14 +485,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
 		}
 		db.get(key.as_ref()).map_err(Error::Db)
 	}
-
-	fn memory_info(&self) -> StateDbMemoryInfo {
-		StateDbMemoryInfo {
-			non_canonical: MemorySize::from_bytes(malloc_size(&self.non_canonical)),
-			pruning: self.pruning.as_ref().map(|p| MemorySize::from_bytes(malloc_size(&p))),
-			pinned: MemorySize::from_bytes(malloc_size(&self.pinned)),
-		}
-	}
 }
 
 /// State DB maintenance. See module description.
@@ -512,9 +493,7 @@ pub struct StateDb<BlockHash: Hash, Key: Hash, D: MetaDb> {
 	db: RwLock<StateDbSync<BlockHash, Key, D>>,
 }
 
-impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
-	StateDb<BlockHash, Key, D>
-{
+impl<BlockHash: Hash, Key: Hash, D: MetaDb> StateDb<BlockHash, Key, D> {
 	/// Create an instance of [`StateDb`].
 	pub fn open(
 		db: D,
@@ -637,11 +616,6 @@ impl<BlockHash: Hash + MallocSizeOf, Key: Hash + MallocSizeOf, D: MetaDb>
 		*state_db = StateDbSync::new(state_db.mode.clone(), state_db.ref_counting, db)?;
 		Ok(())
 	}
-
-	/// Returns the current memory statistics of this instance.
-	pub fn memory_info(&self) -> StateDbMemoryInfo {
-		self.db.read().memory_info()
-	}
 }
 
 /// The result return by `StateDb::is_pruned`
@@ -772,10 +746,8 @@ mod tests {
 
 	#[test]
 	fn block_record_unavailable() {
-		let (mut db, state_db) = make_test_db(PruningMode::Constrained(Constraints {
-			max_blocks: Some(1),
-			max_mem: None,
-		}));
+		let (mut db, state_db) =
+			make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
 		// import 2 blocks
 		for i in &[5, 6] {
 			db.commit(
@@ -809,19 +781,13 @@ mod tests {
 
 	#[test]
 	fn prune_window_0() {
-		let (db, _) = make_test_db(PruningMode::Constrained(Constraints {
-			max_blocks: Some(0),
-			max_mem: None,
-		}));
+		let (db, _) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(0) }));
 		assert!(db.data_eq(&make_db(&[21, 3, 922, 94])));
 	}
 
 	#[test]
 	fn prune_window_1() {
-		let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
-			max_blocks: Some(1),
-			max_mem: None,
-		}));
+		let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(1) }));
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::Pruned);
@@ -831,10 +797,7 @@ mod tests {
 
 	#[test]
 	fn prune_window_2() {
-		let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints {
-			max_blocks: Some(2),
-			max_mem: None,
-		}));
+		let (db, sdb) = make_test_db(PruningMode::Constrained(Constraints { max_blocks: Some(2) }));
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(0), 0), IsPruned::Pruned);
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(1), 1), IsPruned::Pruned);
 		assert_eq!(sdb.is_pruned(&H256::from_low_u64_be(21), 2), IsPruned::NotPruned);
@@ -858,7 +821,7 @@ mod tests {
 				)
 				.unwrap(),
 		);
-		let new_mode = PruningMode::Constrained(Constraints { max_blocks: Some(2), max_mem: None });
+		let new_mode = PruningMode::Constrained(Constraints { max_blocks: Some(2) });
 		let state_db_open_result: Result<(_, StateDb<H256, H256, TestDb>), _> =
 			StateDb::open(db.clone(), Some(new_mode), false, false);
 		assert!(state_db_open_result.is_err());
diff --git a/substrate/client/state-db/src/noncanonical.rs b/substrate/client/state-db/src/noncanonical.rs
index 3711cf7a426670e0b11513f70cf68ffdcac58d87..df09a9c017747b080d34dfd00a345c107202bd6f 100644
--- a/substrate/client/state-db/src/noncanonical.rs
+++ b/substrate/client/state-db/src/noncanonical.rs
@@ -30,7 +30,6 @@ pub(crate) const LAST_CANONICAL: &[u8] = b"last_canonical";
 const MAX_BLOCKS_PER_LEVEL: u64 = 32;
 
 /// See module documentation.
-#[derive(parity_util_mem_derive::MallocSizeOf)]
 pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
 	last_canonicalized: Option<(BlockHash, u64)>,
 	levels: VecDeque<OverlayLevel<BlockHash, Key>>,
@@ -41,7 +40,6 @@ pub struct NonCanonicalOverlay<BlockHash: Hash, Key: Hash> {
 	pinned_insertions: HashMap<BlockHash, (Vec<Key>, u32)>,
 }
 
-#[derive(parity_util_mem_derive::MallocSizeOf)]
 #[cfg_attr(test, derive(PartialEq, Debug))]
 struct OverlayLevel<BlockHash: Hash, Key: Hash> {
 	blocks: Vec<BlockOverlay<BlockHash, Key>>,
@@ -81,7 +79,6 @@ fn to_journal_key(block: u64, index: u64) -> Vec<u8> {
 }
 
 #[cfg_attr(test, derive(PartialEq, Debug))]
-#[derive(parity_util_mem_derive::MallocSizeOf)]
 struct BlockOverlay<BlockHash: Hash, Key: Hash> {
 	hash: BlockHash,
 	journal_index: u64,
diff --git a/substrate/client/state-db/src/pruning.rs b/substrate/client/state-db/src/pruning.rs
index 458522b8119fdf87fffc765cf887f76cab726a44..d942fb2428b6a22f84cf966bbe318b538e0650eb 100644
--- a/substrate/client/state-db/src/pruning.rs
+++ b/substrate/client/state-db/src/pruning.rs
@@ -36,7 +36,6 @@ pub(crate) const LAST_PRUNED: &[u8] = b"last_pruned";
 const PRUNING_JOURNAL: &[u8] = b"pruning_journal";
 
 /// See module documentation.
-#[derive(parity_util_mem_derive::MallocSizeOf)]
 pub struct RefWindow<BlockHash: Hash, Key: Hash, D: MetaDb> {
 	/// A queue of blocks keep tracking keys that should be deleted for each block in the
 	/// pruning window.
@@ -50,7 +49,6 @@ pub struct RefWindow<BlockHash: Hash, Key: Hash, D: MetaDb> {
 /// 	blocks in memory, and keep track of re-inserted keys to not delete them when pruning
 /// - `DbBacked`, used when the backend database supports reference counting, only keep
 /// 	a few number of blocks in memory and load more blocks on demand
-#[derive(parity_util_mem_derive::MallocSizeOf)]
 enum DeathRowQueue<BlockHash: Hash, Key: Hash, D: MetaDb> {
 	Mem {
 		/// A queue of keys that should be deleted for each block in the pruning window.
@@ -60,7 +58,6 @@ enum DeathRowQueue<BlockHash: Hash, Key: Hash, D: MetaDb> {
 	},
 	DbBacked {
 		// The backend database
-		#[ignore_malloc_size_of = "Shared data"]
 		db: D,
 		/// A queue of keys that should be deleted for each block in the pruning window.
 		/// Only caching the first few blocks of the pruning window, blocks inside are
@@ -251,7 +248,7 @@ fn load_death_row_from_db<BlockHash: Hash, Key: Hash, D: MetaDb>(
 	}
 }
 
-#[derive(Clone, Debug, PartialEq, Eq, parity_util_mem_derive::MallocSizeOf)]
+#[derive(Clone, Debug, PartialEq, Eq)]
 struct DeathRow<BlockHash: Hash, Key: Hash> {
 	hash: BlockHash,
 	deleted: HashSet<Key>,
@@ -345,10 +342,6 @@ impl<BlockHash: Hash, Key: Hash, D: MetaDb> RefWindow<BlockHash, Key, D> {
 		Ok(res)
 	}
 
-	pub fn mem_used(&self) -> usize {
-		0
-	}
-
 	fn is_empty(&self) -> bool {
 		self.window_size() == 0
 	}
diff --git a/substrate/client/transaction-pool/Cargo.toml b/substrate/client/transaction-pool/Cargo.toml
index f7f644a6b059bc538f5863925e99648f71b22ff1..7a3ab042d5a131b364e56c7736aebff7131c560e 100644
--- a/substrate/client/transaction-pool/Cargo.toml
+++ b/substrate/client/transaction-pool/Cargo.toml
@@ -19,7 +19,6 @@ futures = "0.3.21"
 futures-timer = "3.0.2"
 linked-hash-map = "0.5.4"
 log = "0.4.17"
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 parking_lot = "0.12.1"
 serde = { version = "1.0.136", features = ["derive"] }
 thiserror = "1.0.30"
diff --git a/substrate/client/transaction-pool/src/graph/base_pool.rs b/substrate/client/transaction-pool/src/graph/base_pool.rs
index 8e0422739cc6353209b35cf669a9d1d11659c4df..67580d698b8c123eab1b309cae4e7a43fb43c08c 100644
--- a/substrate/client/transaction-pool/src/graph/base_pool.rs
+++ b/substrate/client/transaction-pool/src/graph/base_pool.rs
@@ -84,7 +84,7 @@ pub struct PruneStatus<Hash, Ex> {
 
 /// Immutable transaction
 #[cfg_attr(test, derive(Clone))]
-#[derive(PartialEq, Eq, parity_util_mem::MallocSizeOf)]
+#[derive(PartialEq, Eq)]
 pub struct Transaction<Hash, Extrinsic> {
 	/// Raw extrinsic representing that transaction.
 	pub data: Extrinsic,
@@ -207,7 +207,7 @@ const RECENTLY_PRUNED_TAGS: usize = 2;
 /// as-is for the second time will fail or produce unwanted results.
 /// Most likely it is required to revalidate them and recompute set of
 /// required tags.
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct BasePool<Hash: hash::Hash + Eq, Ex> {
 	reject_future_transactions: bool,
 	future: FutureTransactions<Hash, Ex>,
@@ -796,27 +796,6 @@ mod tests {
 		}
 	}
 
-	#[test]
-	fn can_track_heap_size() {
-		let mut pool = pool();
-		pool.import(Transaction {
-			data: vec![5u8; 1024],
-			hash: 5,
-			provides: vec![vec![0], vec![4]],
-			..DEFAULT_TX.clone()
-		})
-		.expect("import 1 should be ok");
-		pool.import(Transaction {
-			data: vec![3u8; 1024],
-			hash: 7,
-			provides: vec![vec![2], vec![7]],
-			..DEFAULT_TX.clone()
-		})
-		.expect("import 2 should be ok");
-
-		assert!(parity_util_mem::malloc_size(&pool) > 5000);
-	}
-
 	#[test]
 	fn should_remove_invalid_transactions() {
 		// given
diff --git a/substrate/client/transaction-pool/src/graph/future.rs b/substrate/client/transaction-pool/src/graph/future.rs
index ae49e3f2d3aed29c1a5da70d46fe0f9eb504a476..d23b5f2b6e1f17202474645a191e8c5bf94e405f 100644
--- a/substrate/client/transaction-pool/src/graph/future.rs
+++ b/substrate/client/transaction-pool/src/graph/future.rs
@@ -28,7 +28,6 @@ use std::time::Instant;
 
 use super::base_pool::Transaction;
 
-#[derive(parity_util_mem::MallocSizeOf)]
 /// Transaction with partially satisfied dependencies.
 pub struct WaitingTransaction<Hash, Ex> {
 	/// Transaction details.
@@ -108,7 +107,7 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
 ///
 /// Contains transactions that are still awaiting for some other transactions that
 /// could provide a tag that they require.
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct FutureTransactions<Hash: hash::Hash + Eq, Ex> {
 	/// tags that are not yet provided by any transaction and we await for them
 	wanted_tags: HashMap<Tag, HashSet<Hash>>,
@@ -251,33 +250,3 @@ impl<Hash: hash::Hash + Eq + Clone, Ex> FutureTransactions<Hash, Ex> {
 		self.waiting.values().fold(0, |acc, tx| acc + tx.transaction.bytes)
 	}
 }
-
-#[cfg(test)]
-mod tests {
-	use super::*;
-	use sp_runtime::transaction_validity::TransactionSource;
-
-	#[test]
-	fn can_track_heap_size() {
-		let mut future = FutureTransactions::default();
-		future.import(WaitingTransaction {
-			transaction: Transaction {
-				data: vec![0u8; 1024],
-				bytes: 1,
-				hash: 1,
-				priority: 1,
-				valid_till: 2,
-				requires: vec![vec![1], vec![2]],
-				provides: vec![vec![3], vec![4]],
-				propagate: true,
-				source: TransactionSource::External,
-			}
-			.into(),
-			missing_tags: vec![vec![1u8], vec![2u8]].into_iter().collect(),
-			imported_at: std::time::Instant::now(),
-		});
-
-		// data is at least 1024!
-		assert!(parity_util_mem::malloc_size(&future) > 1024);
-	}
-}
diff --git a/substrate/client/transaction-pool/src/graph/pool.rs b/substrate/client/transaction-pool/src/graph/pool.rs
index 7b3a8db15982a2fe4c10af885b91386fdbe69950..9c747ade1229a99bc368f2391906a4fd3dd57b7f 100644
--- a/substrate/client/transaction-pool/src/graph/pool.rs
+++ b/substrate/client/transaction-pool/src/graph/pool.rs
@@ -144,15 +144,6 @@ pub struct Pool<B: ChainApi> {
 	validated_pool: Arc<ValidatedPool<B>>,
 }
 
-impl<B: ChainApi> parity_util_mem::MallocSizeOf for Pool<B>
-where
-	ExtrinsicFor<B>: parity_util_mem::MallocSizeOf,
-{
-	fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		self.validated_pool.size_of(ops)
-	}
-}
-
 impl<B: ChainApi> Pool<B> {
 	/// Create a new transaction pool.
 	pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
diff --git a/substrate/client/transaction-pool/src/graph/ready.rs b/substrate/client/transaction-pool/src/graph/ready.rs
index 220e69b13e7eb1c2739e3c464aa73d6baadbfc57..b52372a3c4d10e417b5b126404a2d37655071697 100644
--- a/substrate/client/transaction-pool/src/graph/ready.rs
+++ b/substrate/client/transaction-pool/src/graph/ready.rs
@@ -37,7 +37,7 @@ use super::{
 /// An in-pool transaction reference.
 ///
 /// Should be cheap to clone.
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct TransactionRef<Hash, Ex> {
 	/// The actual transaction data.
 	pub transaction: Arc<Transaction<Hash, Ex>>,
@@ -74,7 +74,7 @@ impl<Hash, Ex> PartialEq for TransactionRef<Hash, Ex> {
 }
 impl<Hash, Ex> Eq for TransactionRef<Hash, Ex> {}
 
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct ReadyTx<Hash, Ex> {
 	/// A reference to a transaction
 	pub transaction: TransactionRef<Hash, Ex>,
@@ -105,7 +105,7 @@ qed
 "#;
 
 /// Validated transactions that are block ready with all their dependencies met.
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct ReadyTransactions<Hash: hash::Hash + Eq, Ex> {
 	/// Next free insertion id (used to indicate when a transaction was inserted into the pool).
 	insertion_id: u64,
@@ -742,25 +742,6 @@ mod tests {
 		assert_eq!(it.next(), None);
 	}
 
-	#[test]
-	fn can_report_heap_size() {
-		let mut ready = ReadyTransactions::default();
-		let tx = Transaction {
-			data: vec![5],
-			bytes: 1,
-			hash: 5,
-			priority: 1,
-			valid_till: u64::MAX, // use the max here for testing.
-			requires: vec![],
-			provides: vec![],
-			propagate: true,
-			source: Source::External,
-		};
-		import(&mut ready, tx).unwrap();
-
-		assert!(parity_util_mem::malloc_size(&ready) > 200);
-	}
-
 	#[test]
 	fn should_order_refs() {
 		let mut id = 1;
diff --git a/substrate/client/transaction-pool/src/graph/tracked_map.rs b/substrate/client/transaction-pool/src/graph/tracked_map.rs
index 32d04b0068877cb5d4670a28f42e5fa15c561fe4..7292293258f5746e3eabde00e9a54af8120f0595 100644
--- a/substrate/client/transaction-pool/src/graph/tracked_map.rs
+++ b/substrate/client/transaction-pool/src/graph/tracked_map.rs
@@ -33,7 +33,7 @@ pub trait Size {
 /// Map with size tracking.
 ///
 /// Size reported might be slightly off and only approximately true.
-#[derive(Debug, parity_util_mem::MallocSizeOf)]
+#[derive(Debug)]
 pub struct TrackedMap<K, V> {
 	index: Arc<RwLock<HashMap<K, V>>>,
 	bytes: AtomicIsize,
diff --git a/substrate/client/transaction-pool/src/graph/validated_pool.rs b/substrate/client/transaction-pool/src/graph/validated_pool.rs
index dcb8195073733c5d3cffcbda1ae28b1751596bc0..ab99a090e5654f9b9dada84b8f371ea291c6e8d1 100644
--- a/substrate/client/transaction-pool/src/graph/validated_pool.rs
+++ b/substrate/client/transaction-pool/src/graph/validated_pool.rs
@@ -110,16 +110,6 @@ pub struct ValidatedPool<B: ChainApi> {
 	rotator: PoolRotator<ExtrinsicHash<B>>,
 }
 
-impl<B: ChainApi> parity_util_mem::MallocSizeOf for ValidatedPool<B>
-where
-	ExtrinsicFor<B>: parity_util_mem::MallocSizeOf,
-{
-	fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		// other entries insignificant or non-primary references
-		self.pool.size_of(ops)
-	}
-}
-
 impl<B: ChainApi> ValidatedPool<B> {
 	/// Create a new transaction pool.
 	pub fn new(options: Options, is_validator: IsValidator, api: Arc<B>) -> Self {
diff --git a/substrate/client/transaction-pool/src/lib.rs b/substrate/client/transaction-pool/src/lib.rs
index a441bf9b2a9a04b93d3bf323dc5a11bf2943857b..0124038b759493a11d9ac201cf23d0ae860a8764 100644
--- a/substrate/client/transaction-pool/src/lib.rs
+++ b/substrate/client/transaction-pool/src/lib.rs
@@ -135,17 +135,6 @@ impl<T, Block: BlockT> ReadyPoll<T, Block> {
 	}
 }
 
-impl<PoolApi, Block> parity_util_mem::MallocSizeOf for BasicPool<PoolApi, Block>
-where
-	PoolApi: graph::ChainApi<Block = Block>,
-	Block: BlockT,
-{
-	fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		// other entries insignificant or non-primary references
-		self.pool.size_of(ops)
-	}
-}
-
 /// Type of revalidation.
 pub enum RevalidationType {
 	/// Light revalidation type.
diff --git a/substrate/client/transaction-pool/tests/pool.rs b/substrate/client/transaction-pool/tests/pool.rs
index 27891432753a4b236e311eb8c1c87f611efa4cb4..7ba61e58b4cb549a30c4749edb813fd7d40b6aae 100644
--- a/substrate/client/transaction-pool/tests/pool.rs
+++ b/substrate/client/transaction-pool/tests/pool.rs
@@ -440,17 +440,6 @@ fn should_push_watchers_during_maintenance() {
 	);
 }
 
-#[test]
-fn can_track_heap_size() {
-	let (pool, _api, _guard) = maintained_pool();
-	block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 209))).expect("1. Imported");
-	block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 210))).expect("1. Imported");
-	block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 211))).expect("1. Imported");
-	block_on(pool.submit_one(&BlockId::number(0), SOURCE, uxt(Alice, 212))).expect("1. Imported");
-
-	assert!(parity_util_mem::malloc_size(&pool) > 3000);
-}
-
 #[test]
 fn finalization() {
 	let xt = uxt(Alice, 209);
diff --git a/substrate/frame/support/Cargo.toml b/substrate/frame/support/Cargo.toml
index b199c014d35ed344d907e100016f2843722bf3a8..4945b5ab915f975f03a098814b21cbe3b172397a 100644
--- a/substrate/frame/support/Cargo.toml
+++ b/substrate/frame/support/Cargo.toml
@@ -44,7 +44,6 @@ serde_json = "1.0.85"
 assert_matches = "1.3.0"
 pretty_assertions = "1.2.1"
 frame-system = { version = "4.0.0-dev", path = "../system" }
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 
 [features]
 default = ["std"]
diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs
index 7c4c4683958e3c001d8c3643497e108c189af0d1..f7e3849beeb8d8265d4243c25c3509e32c68edca 100644
--- a/substrate/frame/system/src/lib.rs
+++ b/substrate/frame/system/src/lib.rs
@@ -72,7 +72,7 @@ use sp_runtime::{
 	generic,
 	traits::{
 		self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded,
-		CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf,
+		CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay,
 		MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero,
 	},
 	DispatchError, RuntimeDebug,
@@ -250,7 +250,6 @@ pub mod pallet {
 			+ Copy
 			+ sp_std::hash::Hash
 			+ sp_std::str::FromStr
-			+ MaybeMallocSizeOf
 			+ MaxEncodedLen
 			+ TypeInfo;
 
@@ -268,7 +267,6 @@ pub mod pallet {
 			+ sp_std::hash::Hash
 			+ AsRef<[u8]>
 			+ AsMut<[u8]>
-			+ MaybeMallocSizeOf
 			+ MaxEncodedLen;
 
 		/// The hashing system (algorithm) being used in the runtime (e.g. Blake2).
diff --git a/substrate/primitives/database/Cargo.toml b/substrate/primitives/database/Cargo.toml
index f19a647fed03241104532b5817dd41f87bea856a..b1105f88ba50f4a71cd5f072e6444a60c08e15ff 100644
--- a/substrate/primitives/database/Cargo.toml
+++ b/substrate/primitives/database/Cargo.toml
@@ -11,5 +11,5 @@ documentation = "https://docs.rs/sp-database"
 readme = "README.md"
 
 [dependencies]
-kvdb = "0.12.0"
+kvdb = "0.13.0"
 parking_lot = "0.12.1"
diff --git a/substrate/primitives/runtime/Cargo.toml b/substrate/primitives/runtime/Cargo.toml
index 578c01583f87c96e98449b4e7169d2ae42658796..8ea6ed3eb3b19e327fdc5b0b3085a3503beb9144 100644
--- a/substrate/primitives/runtime/Cargo.toml
+++ b/substrate/primitives/runtime/Cargo.toml
@@ -19,7 +19,6 @@ either = { version = "1.5", default-features = false }
 hash256-std-hasher = { version = "0.15.2", default-features = false }
 impl-trait-for-tuples = "0.2.2"
 log = { version = "0.4.17", default-features = false }
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"], optional = true }
 paste = "1.0"
 rand = { version = "0.7.2", optional = true }
 scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
@@ -48,7 +47,6 @@ std = [
 	"either/use_std",
 	"hash256-std-hasher/std",
 	"log/std",
-	"parity-util-mem/std",
 	"rand",
 	"scale-info/std",
 	"serde",
diff --git a/substrate/primitives/runtime/src/generic/block.rs b/substrate/primitives/runtime/src/generic/block.rs
index 2cd350b2c5ba1628e02d8fad2db4c1d3b25fc5e8..3b01633635c24e29f4e156a19f32fca0d24a5010 100644
--- a/substrate/primitives/runtime/src/generic/block.rs
+++ b/substrate/primitives/runtime/src/generic/block.rs
@@ -25,10 +25,7 @@ use serde::{Deserialize, Serialize};
 
 use crate::{
 	codec::{Codec, Decode, Encode},
-	traits::{
-		self, Block as BlockT, Header as HeaderT, MaybeMallocSizeOf, MaybeSerialize, Member,
-		NumberFor,
-	},
+	traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor},
 	Justifications,
 };
 use sp_core::RuntimeDebug;
@@ -82,7 +79,7 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
 
 /// Abstraction over a substrate block.
 #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, parity_util_mem::MallocSizeOf))]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
 #[cfg_attr(feature = "std", serde(deny_unknown_fields))]
 pub struct Block<Header, Extrinsic: MaybeSerialize> {
@@ -95,7 +92,7 @@ pub struct Block<Header, Extrinsic: MaybeSerialize> {
 impl<Header, Extrinsic: MaybeSerialize> traits::Block for Block<Header, Extrinsic>
 where
 	Header: HeaderT,
-	Extrinsic: Member + Codec + traits::Extrinsic + MaybeMallocSizeOf,
+	Extrinsic: Member + Codec + traits::Extrinsic,
 {
 	type Extrinsic = Extrinsic;
 	type Header = Header;
diff --git a/substrate/primitives/runtime/src/generic/digest.rs b/substrate/primitives/runtime/src/generic/digest.rs
index ec74ebb0d4e15792f3e81e1b22c1a2772db250c2..1d1173057ea8d52a17edcd35ec024bbe3a9d47e1 100644
--- a/substrate/primitives/runtime/src/generic/digest.rs
+++ b/substrate/primitives/runtime/src/generic/digest.rs
@@ -34,7 +34,7 @@ use sp_core::RuntimeDebug;
 
 /// Generic header digest.
 #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)]
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, parity_util_mem::MallocSizeOf))]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 pub struct Digest {
 	/// A list of logs in the digest.
 	pub logs: Vec<DigestItem>,
@@ -70,7 +70,6 @@ impl Digest {
 /// Digest item that is able to encode/decode 'system' digest items and
 /// provide opaque access to other items.
 #[derive(PartialEq, Eq, Clone, RuntimeDebug)]
-#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
 pub enum DigestItem {
 	/// A pre-runtime digest.
 	///
diff --git a/substrate/primitives/runtime/src/generic/header.rs b/substrate/primitives/runtime/src/generic/header.rs
index a7b43608f2b78ca3ddf7a9afd8568a2a88491590..04d09f6b155419d903eb8d552be99f4785b91d15 100644
--- a/substrate/primitives/runtime/src/generic/header.rs
+++ b/substrate/primitives/runtime/src/generic/header.rs
@@ -22,7 +22,7 @@ use crate::{
 	generic::Digest,
 	scale_info::TypeInfo,
 	traits::{
-		self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeMallocSizeOf, MaybeSerialize,
+		self, AtLeast32BitUnsigned, Hash as HashT, MaybeDisplay, MaybeSerialize,
 		MaybeSerializeDeserialize, Member, SimpleBitOps,
 	},
 };
@@ -54,22 +54,6 @@ pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
 	pub digest: Digest,
 }
 
-#[cfg(feature = "std")]
-impl<Number, Hash> parity_util_mem::MallocSizeOf for Header<Number, Hash>
-where
-	Number: Copy + Into<U256> + TryFrom<U256> + parity_util_mem::MallocSizeOf,
-	Hash: HashT,
-	Hash::Output: parity_util_mem::MallocSizeOf,
-{
-	fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		self.parent_hash.size_of(ops) +
-			self.number.size_of(ops) +
-			self.state_root.size_of(ops) +
-			self.extrinsics_root.size_of(ops) +
-			self.digest.size_of(ops)
-	}
-}
-
 #[cfg(feature = "std")]
 pub fn serialize_number<S, T: Copy + Into<U256> + TryFrom<U256>>(
 	val: &T,
@@ -103,8 +87,7 @@ where
 		+ Copy
 		+ Into<U256>
 		+ TryFrom<U256>
-		+ sp_std::str::FromStr
-		+ MaybeMallocSizeOf,
+		+ sp_std::str::FromStr,
 	Hash: HashT,
 	Hash::Output: Default
 		+ sp_std::hash::Hash
@@ -115,8 +98,7 @@ where
 		+ Debug
 		+ MaybeDisplay
 		+ SimpleBitOps
-		+ Codec
-		+ MaybeMallocSizeOf,
+		+ Codec,
 {
 	type Number = Number;
 	type Hash = <Hash as HashT>::Output;
diff --git a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs
index fb333abd6ac6e3d13254cf50e1efd72f3f855204..5d378410e47561a0dd56658e0cbe2b4aa276c758 100644
--- a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs
+++ b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs
@@ -87,18 +87,6 @@ where
 	}
 }
 
-#[cfg(feature = "std")]
-impl<Address, Call, Signature, Extra> parity_util_mem::MallocSizeOf
-	for UncheckedExtrinsic<Address, Call, Signature, Extra>
-where
-	Extra: SignedExtension,
-{
-	fn size_of(&self, _ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		// Instantiated only in runtime.
-		0
-	}
-}
-
 impl<Address, Call, Signature, Extra: SignedExtension>
 	UncheckedExtrinsic<Address, Call, Signature, Extra>
 {
diff --git a/substrate/primitives/runtime/src/lib.rs b/substrate/primitives/runtime/src/lib.rs
index 3752e31cbeeb099773746ea6a8ade1bc43b1d729..e94efda86aa03b3f250ba67b64c8c1311218ae29 100644
--- a/substrate/primitives/runtime/src/lib.rs
+++ b/substrate/primitives/runtime/src/lib.rs
@@ -874,13 +874,6 @@ impl OpaqueExtrinsic {
 	}
 }
 
-#[cfg(feature = "std")]
-impl parity_util_mem::MallocSizeOf for OpaqueExtrinsic {
-	fn size_of(&self, ops: &mut parity_util_mem::MallocSizeOfOps) -> usize {
-		self.0.size_of(ops)
-	}
-}
-
 impl sp_std::fmt::Debug for OpaqueExtrinsic {
 	#[cfg(feature = "std")]
 	fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
diff --git a/substrate/primitives/runtime/src/testing.rs b/substrate/primitives/runtime/src/testing.rs
index d16a37e6a2059126c9c238baeb854fe7b0051960..0cd78ba6267dd1d23ac8e3ce703526b770d7ceb4 100644
--- a/substrate/primitives/runtime/src/testing.rs
+++ b/substrate/primitives/runtime/src/testing.rs
@@ -204,13 +204,10 @@ impl Header {
 }
 
 /// An opaque extrinsic wrapper type.
-#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode, parity_util_mem::MallocSizeOf)]
+#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode)]
 pub struct ExtrinsicWrapper<Xt>(Xt);
 
-impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt>
-where
-	Xt: parity_util_mem::MallocSizeOf,
-{
+impl<Xt> traits::Extrinsic for ExtrinsicWrapper<Xt> {
 	type Call = ();
 	type SignaturePayload = ();
 
@@ -243,7 +240,7 @@ impl<Xt> Deref for ExtrinsicWrapper<Xt> {
 }
 
 /// Testing block
-#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode, parity_util_mem::MallocSizeOf)]
+#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode)]
 pub struct Block<Xt> {
 	/// Block header
 	pub header: Header,
@@ -306,9 +303,6 @@ impl<Call, Extra> TestXt<Call, Extra> {
 	}
 }
 
-// Non-opaque extrinsics always 0.
-parity_util_mem::malloc_size_of_is_0!(any: TestXt<Call, Extra>);
-
 impl<Call, Extra> Serialize for TestXt<Call, Extra>
 where
 	TestXt<Call, Extra>: Encode,
diff --git a/substrate/primitives/runtime/src/traits.rs b/substrate/primitives/runtime/src/traits.rs
index 276a62349a17599a37f435dffc359d5fab9a5865..6af711cba8e50c1ba3152e2c95a38ddd79c0d9bd 100644
--- a/substrate/primitives/runtime/src/traits.rs
+++ b/substrate/primitives/runtime/src/traits.rs
@@ -808,9 +808,6 @@ sp_core::impl_maybe_marker!(
 
 	/// A type that implements Serialize, DeserializeOwned and Debug when in std environment.
 	trait MaybeSerializeDeserialize: DeserializeOwned, Serialize;
-
-	/// A type that implements MallocSizeOf.
-	trait MaybeMallocSizeOf: parity_util_mem::MallocSizeOf;
 );
 
 /// A type that can be used in runtime structures.
@@ -828,9 +825,7 @@ pub trait IsMember<MemberId> {
 /// `parent_hash`, as well as a `digest` and a block `number`.
 ///
 /// You can also create a `new` one from those fields.
-pub trait Header:
-	Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
-{
+pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
 	/// Header number.
 	type Number: Member
 		+ MaybeSerializeDeserialize
@@ -840,8 +835,7 @@ pub trait Header:
 		+ MaybeDisplay
 		+ AtLeast32BitUnsigned
 		+ Codec
-		+ sp_std::str::FromStr
-		+ MaybeMallocSizeOf;
+		+ sp_std::str::FromStr;
 	/// Header hash type
 	type Hash: Member
 		+ MaybeSerializeDeserialize
@@ -855,7 +849,6 @@ pub trait Header:
 		+ Codec
 		+ AsRef<[u8]>
 		+ AsMut<[u8]>
-		+ MaybeMallocSizeOf
 		+ TypeInfo;
 	/// Hashing algorithm
 	type Hashing: Hash<Output = Self::Hash>;
@@ -904,13 +897,11 @@ pub trait Header:
 /// `Extrinsic` pieces of information as well as a `Header`.
 ///
 /// You can get an iterator over each of the `extrinsics` and retrieve the `header`.
-pub trait Block:
-	Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + MaybeMallocSizeOf + 'static
-{
+pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static {
 	/// Type for extrinsics.
-	type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize + MaybeMallocSizeOf;
+	type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize;
 	/// Header type.
-	type Header: Header<Hash = Self::Hash> + MaybeMallocSizeOf;
+	type Header: Header<Hash = Self::Hash>;
 	/// Block hash type.
 	type Hash: Member
 		+ MaybeSerializeDeserialize
@@ -924,7 +915,6 @@ pub trait Block:
 		+ Codec
 		+ AsRef<[u8]>
 		+ AsMut<[u8]>
-		+ MaybeMallocSizeOf
 		+ TypeInfo;
 
 	/// Returns a reference to the header.
@@ -945,7 +935,7 @@ pub trait Block:
 }
 
 /// Something that acts like an `Extrinsic`.
-pub trait Extrinsic: Sized + MaybeMallocSizeOf {
+pub trait Extrinsic: Sized {
 	/// The function call.
 	type Call;
 
diff --git a/substrate/primitives/runtime/src/transaction_validity.rs b/substrate/primitives/runtime/src/transaction_validity.rs
index d8e71cc2761ec812502559f270fb5c7f9ce1adb4..3b89644c286479a07f8303e1a470a30e3940aaf4 100644
--- a/substrate/primitives/runtime/src/transaction_validity.rs
+++ b/substrate/primitives/runtime/src/transaction_validity.rs
@@ -227,7 +227,6 @@ impl From<UnknownTransaction> for TransactionValidity {
 /// For instance we can disallow specific kinds of transactions if they were not produced
 /// by our local node (for instance off-chain workers).
 #[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
-#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
 pub enum TransactionSource {
 	/// Transaction is already included in block.
 	///
diff --git a/substrate/primitives/test-primitives/Cargo.toml b/substrate/primitives/test-primitives/Cargo.toml
index 6cfd17afcc5fd43a784fa40b54fbf1d06da0307e..1d12ed74ee6ce6ef23fa58027342cafe2251f3cc 100644
--- a/substrate/primitives/test-primitives/Cargo.toml
+++ b/substrate/primitives/test-primitives/Cargo.toml
@@ -13,7 +13,6 @@ targets = ["x86_64-unknown-linux-gnu"]
 
 [dependencies]
 codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 serde = { version = "1.0.136", features = ["derive"], optional = true }
 sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" }
 sp-core = { version = "7.0.0", default-features = false, path = "../core" }
@@ -25,7 +24,6 @@ default = [
 ]
 std = [
 	"codec/std",
-	"parity-util-mem/std",
 	"serde",
 	"sp-application-crypto/std",
 	"sp-core/std",
diff --git a/substrate/primitives/test-primitives/src/lib.rs b/substrate/primitives/test-primitives/src/lib.rs
index 976bb9ddd9cd7ec1a73bca0d066879eabd1e9e7f..9779fe2393c354a65e7c11aa986aa221f25fa90d 100644
--- a/substrate/primitives/test-primitives/src/lib.rs
+++ b/substrate/primitives/test-primitives/src/lib.rs
@@ -29,7 +29,6 @@ use sp_runtime::traits::{BlakeTwo256, Extrinsic as ExtrinsicT, Verify};
 
 /// Extrinsic for test-runtime.
 #[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
-#[cfg_attr(feature = "std", derive(parity_util_mem::MallocSizeOf))]
 pub enum Extrinsic {
 	IncludeData(Vec<u8>),
 	StorageChange(Vec<u8>, Option<Vec<u8>>),
diff --git a/substrate/primitives/trie/Cargo.toml b/substrate/primitives/trie/Cargo.toml
index 67839a157a02b21db08fbdab58f6a0f643f56f6e..68a5fb17c3c344b29658b175b4a69e05333dca4c 100644
--- a/substrate/primitives/trie/Cargo.toml
+++ b/substrate/primitives/trie/Cargo.toml
@@ -24,7 +24,7 @@ hashbrown = { version = "0.12.3", optional = true }
 hash-db = { version = "0.15.2", default-features = false }
 lazy_static = { version = "1.4.0", optional = true }
 lru = { version = "0.8.1", optional = true }
-memory-db = { version = "0.30.0", default-features = false }
+memory-db = { version = "0.31.0", default-features = false }
 nohash-hasher = { version = "0.2.0", optional = true }
 parking_lot = { version = "0.12.1", optional = true }
 scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
@@ -38,7 +38,7 @@ sp-std = { version = "5.0.0", default-features = false, path = "../std" }
 [dev-dependencies]
 array-bytes = "4.1"
 criterion = "0.3.3"
-trie-bench = "0.32.0"
+trie-bench = "0.33.0"
 trie-standardmap = "0.15.2"
 sp-runtime = { version = "7.0.0", path = "../runtime" }
 
@@ -62,4 +62,3 @@ std = [
 	"trie-db/std",
 	"trie-root/std",
 ]
-memory-tracker = []
diff --git a/substrate/primitives/trie/src/lib.rs b/substrate/primitives/trie/src/lib.rs
index d036db7b1fecd308931829889be7ba883e51c08e..01650e9a376be0b842caeb4b2647aaaef6f1e65c 100644
--- a/substrate/primitives/trie/src/lib.rs
+++ b/substrate/primitives/trie/src/lib.rs
@@ -146,11 +146,6 @@ where
 	}
 }
 
-#[cfg(not(feature = "memory-tracker"))]
-type MemTracker = memory_db::NoopTracker<trie_db::DBValue>;
-#[cfg(feature = "memory-tracker")]
-type MemTracker = memory_db::MemCounter<trie_db::DBValue>;
-
 /// TrieDB error over `TrieConfiguration` trait.
 pub type TrieError<L> = trie_db::TrieError<TrieHash<L>, CError<L>>;
 /// Reexport from `hash_db`, with genericity set for `Hasher` trait.
@@ -161,14 +156,13 @@ pub type HashDB<'a, H> = dyn hash_db::HashDB<H, trie_db::DBValue> + 'a;
 /// Reexport from `hash_db`, with genericity set for `Hasher` trait.
 /// This uses a `KeyFunction` for prefixing keys internally (avoiding
 /// key conflict for non random keys).
-pub type PrefixedMemoryDB<H> =
-	memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue, MemTracker>;
+pub type PrefixedMemoryDB<H> = memory_db::MemoryDB<H, memory_db::PrefixedKey<H>, trie_db::DBValue>;
 /// Reexport from `hash_db`, with genericity set for `Hasher` trait.
 /// This uses a noops `KeyFunction` (key addressing must be hashed or using
 /// an encoding scheme that avoid key conflict).
-pub type MemoryDB<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue, MemTracker>;
+pub type MemoryDB<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue>;
 /// Reexport from `hash_db`, with genericity set for `Hasher` trait.
-pub type GenericMemoryDB<H, KF> = memory_db::MemoryDB<H, KF, trie_db::DBValue, MemTracker>;
+pub type GenericMemoryDB<H, KF> = memory_db::MemoryDB<H, KF, trie_db::DBValue>;
 
 /// Persistent trie database read-access interface for the a given hasher.
 pub type TrieDB<'a, 'cache, L> = trie_db::TrieDB<'a, 'cache, L>;
@@ -548,8 +542,7 @@ mod tests {
 	type LayoutV0 = super::LayoutV0<Blake2Hasher>;
 	type LayoutV1 = super::LayoutV1<Blake2Hasher>;
 
-	type MemoryDBMeta<H> =
-		memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue, MemTracker>;
+	type MemoryDBMeta<H> = memory_db::MemoryDB<H, memory_db::HashKey<H>, trie_db::DBValue>;
 
 	fn hashed_null_node<T: TrieConfiguration>() -> TrieHash<T> {
 		<T::Codec as NodeCodecT>::hashed_null_node()
diff --git a/substrate/scripts/ci/deny.toml b/substrate/scripts/ci/deny.toml
index 8cc7635d5049be795e994b0ba740d9273b2f520f..bc41f746cbb1e84b27121917959b1cace5f452a1 100644
--- a/substrate/scripts/ci/deny.toml
+++ b/substrate/scripts/ci/deny.toml
@@ -160,7 +160,6 @@ allow = [
 ]
 # List of crates to deny
 deny = [
-    { name = "parity-util-mem", version = "<0.6" }
     # Each entry the name of a crate and a version range. If version is
     # not specified, all versions will be matched.
 ]
diff --git a/substrate/test-utils/runtime/Cargo.toml b/substrate/test-utils/runtime/Cargo.toml
index a201906f1cc4dafc964a5071b8eb4cba96a81460..7576a63ac3eb1ce1ba4ef45d8d05c667e3ea8bc9 100644
--- a/substrate/test-utils/runtime/Cargo.toml
+++ b/substrate/test-utils/runtime/Cargo.toml
@@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
 scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
 sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" }
 sp-keyring = { version = "7.0.0", optional = true, path = "../../primitives/keyring" }
-memory-db = { version = "0.30.0", default-features = false }
+memory-db = { version = "0.31.0", default-features = false }
 sp-offchain = { version = "4.0.0-dev", default-features = false, path = "../../primitives/offchain" }
 sp-core = { version = "7.0.0", default-features = false, path = "../../primitives/core" }
 sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
@@ -42,7 +42,6 @@ sp-finality-grandpa = { version = "4.0.0-dev", default-features = false, path =
 sp-trie = { version = "7.0.0", default-features = false, path = "../../primitives/trie" }
 sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../primitives/transaction-pool" }
 trie-db = { version = "0.24.0", default-features = false }
-parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
 sc-service = { version = "0.10.0-dev", default-features = false, optional = true, features = ["test-helpers"], path = "../../client/service" }
 sp-state-machine = { version = "0.13.0", default-features = false, path = "../../primitives/state-machine" }
 sp-externalities = { version = "0.13.0", default-features = false, path = "../../primitives/externalities" }
@@ -67,7 +66,6 @@ default = [
 	"std",
 ]
 std = [
-	"parity-util-mem/std",
 	"beefy-primitives/std",
 	"beefy-merkle-tree/std",
 	"sp-application-crypto/std",
diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs
index 51f057e3ded5511ac780bb24af24c7473a49ff76..8b64528e243bd7cefb7469997d2072a28ebb501b 100644
--- a/substrate/test-utils/runtime/src/lib.rs
+++ b/substrate/test-utils/runtime/src/lib.rs
@@ -166,8 +166,6 @@ pub enum Extrinsic {
 	Store(Vec<u8>),
 }
 
-parity_util_mem::malloc_size_of_is_0!(Extrinsic); // non-opaque extrinsic does not need this
-
 #[cfg(feature = "std")]
 impl serde::Serialize for Extrinsic {
 	fn serialize<S>(&self, seq: S) -> Result<S::Ok, S::Error>
diff --git a/substrate/utils/frame/benchmarking-cli/Cargo.toml b/substrate/utils/frame/benchmarking-cli/Cargo.toml
index 1b38f0295f8bbf0c4f3f3def4d9ac005bc76676f..5173340f7d0d91941f0311d7a055ac5971774bd5 100644
--- a/substrate/utils/frame/benchmarking-cli/Cargo.toml
+++ b/substrate/utils/frame/benchmarking-cli/Cargo.toml
@@ -22,11 +22,11 @@ handlebars = "4.2.2"
 hash-db = "0.15.2"
 Inflector = "0.11.4"
 itertools = "0.10.3"
-kvdb = "0.12.0"
+kvdb = "0.13.0"
 lazy_static = "1.4.0"
 linked-hash-map = "0.5.4"
 log = "0.4.17"
-memory-db = "0.30.0"
+memory-db = "0.31.0"
 rand = { version = "0.8.4", features = ["small_rng"] }
 rand_pcg = "0.3.1"
 serde = "1.0.136"