Remove calls to heapsize (#10432)
* update memorydb trait * use malloc_size_of instead of heapsize_of * use jemalloc as default allocator for parity client.
This commit is contained in:
@@ -18,10 +18,10 @@
|
||||
//! crate.
|
||||
// TODO: push changes upstream in a clean way.
|
||||
|
||||
extern crate heapsize;
|
||||
extern crate parity_util_mem;
|
||||
extern crate lru_cache;
|
||||
|
||||
use heapsize::HeapSizeOf;
|
||||
use parity_util_mem::{MallocSizeOf, MallocSizeOfExt};
|
||||
use lru_cache::LruCache;
|
||||
|
||||
use std::hash::Hash;
|
||||
@@ -29,18 +29,18 @@ use std::hash::Hash;
|
||||
const INITIAL_CAPACITY: usize = 4;
|
||||
|
||||
/// An LRU-cache which operates on memory used.
|
||||
pub struct MemoryLruCache<K: Eq + Hash, V: HeapSizeOf> {
|
||||
pub struct MemoryLruCache<K: Eq + Hash, V> {
|
||||
inner: LruCache<K, V>,
|
||||
cur_size: usize,
|
||||
max_size: usize,
|
||||
}
|
||||
|
||||
// amount of memory used when the item will be put on the heap.
|
||||
fn heap_size_of<T: HeapSizeOf>(val: &T) -> usize {
|
||||
::std::mem::size_of::<T>() + val.heap_size_of_children()
|
||||
fn heap_size_of<T: MallocSizeOf>(val: &T) -> usize {
|
||||
::std::mem::size_of::<T>() + val.malloc_size_of()
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash, V: HeapSizeOf> MemoryLruCache<K, V> {
|
||||
impl<K: Eq + Hash, V: MallocSizeOf> MemoryLruCache<K, V> {
|
||||
/// Create a new cache with a maximum size in bytes.
|
||||
pub fn new(max_size: usize) -> Self {
|
||||
MemoryLruCache {
|
||||
|
||||
Reference in New Issue
Block a user