adamreeve commented on code in PR #8898:
URL: https://github.com/apache/arrow-rs/pull/8898#discussion_r2547813556
##########
parquet/src/file/metadata/memory.rs:
##########
@@ -95,21 +95,16 @@ impl<K: HeapSize, V: HeapSize> HeapSize for HashMap<K, V> {
impl<T: HeapSize> HeapSize for Arc<T> {
fn heap_size(&self) -> usize {
- // Arc stores weak and strong counts on the heap alongside an instance
of T
- 2 * std::mem::size_of::<usize>() + std::mem::size_of::<T>() +
self.as_ref().heap_size()
- }
-}
-
-impl HeapSize for Arc<dyn HeapSize> {
- fn heap_size(&self) -> usize {
- 2 * std::mem::size_of::<usize>()
- + std::mem::size_of_val(self.as_ref())
- + self.as_ref().heap_size()
+ // Do not count the size of the Arc itself that is accounted for by the
+ // caller (the object that contains the Arc).
+ std::mem::size_of::<T>() + self.as_ref().heap_size()
Review Comment:
The strong and weak counts are stored on the heap so aren't included in
`std::mem::size_of::<T>()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]