Skip to content

Commit

Permalink
Fix the memory size computation
Browse files Browse the repository at this point in the history
Summary: Make sure you include the header size.

Reviewed By: krallin

Differential Revision: D30939478

fbshipit-source-id: ea1b56e2685b8a11eab9d26ca734b8ff9d87b253
  • Loading branch information
ndmitchell authored and facebook-github-bot committed Sep 14, 2021
1 parent 5494083 commit 89b0c9c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Arena {
.entry(x.dupe())
.or_insert_with(|| (v.get_type(), (0, 0)));
e.1.0 += 1;
e.1.1 += v.memory_size() + v.extra_memory();
e.1.1 += mem::size_of::<AValueHeader>() + v.memory_size() + v.extra_memory();
};
for_each(&self.drop, &mut f);
for_each(&self.non_drop, &mut f);
Expand Down Expand Up @@ -476,6 +476,8 @@ mod test {
arena.alloc(mk_str("test"));
let res = arena.allocated_summary().summary;
assert_eq!(res.len(), 1);
assert_eq!(res.values().next().unwrap().0, 2);
let entry = res.values().next().unwrap();
assert_eq!(entry.0, 2);
assert_eq!(entry.1, arena.allocated_bytes())
}
}

0 comments on commit 89b0c9c

Please sign in to comment.