File tree 1 file changed +6
-1
lines changed
starlark/src/values/layout/heap
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,11 @@ impl<'c> Iterator for ChunkIter<'c> {
140
140
}
141
141
142
142
impl Arena {
143
+ /// Number of allocated bytes plus padding size.
143
144
pub fn allocated_bytes ( & self ) -> usize {
145
+ // This overestimates the allocates size, see `Bump::allocated_bytes()`:
146
+ // "those padding bytes will add to this method’s resulting sum".
147
+ // https://docs.rs/bumpalo/3.11.0/bumpalo/struct.Bump.html#method.allocated_bytes
144
148
self . drop . allocated_bytes ( ) + self . non_drop . allocated_bytes ( )
145
149
}
146
150
@@ -510,6 +514,7 @@ mod tests {
510
514
assert_eq ! ( res. len( ) , 1 ) ;
511
515
let entry = res. values ( ) . next ( ) . unwrap ( ) ;
512
516
assert_eq ! ( entry. count, 2 ) ;
513
- assert_eq ! ( entry. bytes, arena. allocated_bytes( ) ) ;
517
+ // Because `arena.allocated_bytes` over-approximates.
518
+ assert ! ( entry. bytes <= arena. allocated_bytes( ) ) ;
514
519
}
515
520
}
You can’t perform that action at this time.
0 commit comments