You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This accounts for sizeof T stored inside the Arc, as well as sizeof of the Arc itself (fat or thin pointer). However, it misses the two counters that are stored in the ArcInner. In parcicular this currently returns 8: crate::size_of_val(&Arc::new(())). I'd expect 24 instead -- one usize for the pointer + 2 * usize for strong and weak count.
The text was updated successfully, but these errors were encountered:
Yeah, it's a bit tricky. The only difference between size_of and size_of_val is in handling DST.
For Arc, the size_of is just a single pointer to the ArcInner heap allocated box. There isn't a function which can tell you the size of this box itself, you'll have to hard-code it.
Well, I guess there is a way to get this size without hard-coding, by asking the allocator about it. This is what servo's analogue dose:
loupe/crates/loupe/src/memory_usage/sync.rs
Lines 46 to 52 in 3108424
This accounts for sizeof
T
stored inside the Arc, as well as sizeof of the Arc itself (fat or thin pointer). However, it misses the two counters that are stored in theArcInner
. In parcicular this currently returns 8:crate::size_of_val(&Arc::new(()))
. I'd expect 24 instead -- oneusize
for the pointer +2 * usize
for strong and weak count.The text was updated successfully, but these errors were encountered: