heapsize icon indicating copy to clipboard operation
heapsize copied to clipboard

Unexpected result from heap_size_of_children

Open cswinter opened this issue 6 years ago • 0 comments

Noob question:

I have an enum with a variant that contains just a Vec<u8>. I derive HeapSizeOf on the enum using the macro from the heapsize_derive crate. Results are the same when I manually implement HeapSizeOf by calling heap_size_of_children on the inner values.

When I query the inner len and capacity of the vector I get 4194575. When I call heap_size_of_children on the enum, I get 5242880. Where could that extra size come from? I'm thinking allocator overhead, is heapsize able to account for that? Memory usage reported by the OS actually agrees with the smaller number, but I suppose the additional pages would not have been touched.

Maybe relevant?

  • I called shrink_to_fit on the vector
  • I'm running under WSL which should be linking jemalloc

cswinter avatar Jul 28 '18 18:07 cswinter