File tree 4 files changed +51
-12
lines changed
4 files changed +51
-12
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ pub struct AllocatorReport {
66
66
pub blocks : Vec < MemoryBlockReport > ,
67
67
/// Sum of the memory used by all allocations, in bytes.
68
68
pub total_allocated_bytes : u64 ,
69
- /// Sum of the memory reserved by all memory blocks including unallocated regions, in bytes.
70
- pub total_reserved_bytes : u64 ,
69
+ /// Sum of the memory capacity of all memory blocks including unallocated regions, in bytes.
70
+ pub total_capacity_bytes : u64 ,
71
71
}
72
72
73
73
impl fmt:: Debug for AllocationReport {
@@ -95,7 +95,7 @@ impl fmt::Debug for AllocatorReport {
95
95
& core:: format_args!(
96
96
"{} / {}" ,
97
97
fmt_bytes( self . total_allocated_bytes) ,
98
- fmt_bytes( self . total_reserved_bytes )
98
+ fmt_bytes( self . total_capacity_bytes )
99
99
) ,
100
100
)
101
101
. field ( "blocks" , & self . blocks . len ( ) )
Original file line number Diff line number Diff line change @@ -1141,11 +1141,11 @@ impl Allocator {
1141
1141
pub fn generate_report ( & self ) -> AllocatorReport {
1142
1142
let mut allocations = vec ! [ ] ;
1143
1143
let mut blocks = vec ! [ ] ;
1144
- let mut total_reserved_bytes = 0 ;
1144
+ let mut total_capacity_bytes = 0 ;
1145
1145
1146
1146
for memory_type in & self . memory_types {
1147
1147
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
1148
- total_reserved_bytes += block. size ;
1148
+ total_capacity_bytes += block. size ;
1149
1149
let first_allocation = allocations. len ( ) ;
1150
1150
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
1151
1151
blocks. push ( MemoryBlockReport {
@@ -1161,9 +1161,22 @@ impl Allocator {
1161
1161
allocations,
1162
1162
blocks,
1163
1163
total_allocated_bytes,
1164
- total_reserved_bytes ,
1164
+ total_capacity_bytes ,
1165
1165
}
1166
1166
}
1167
+
1168
+ /// Current total capacity of memory blocks allocated on the device, in bytes
1169
+ pub fn capacity ( & self ) -> u64 {
1170
+ let mut total_capacity_bytes = 0 ;
1171
+
1172
+ for memory_type in & self . memory_types {
1173
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
1174
+ total_capacity_bytes += block. size ;
1175
+ }
1176
+ }
1177
+
1178
+ total_capacity_bytes
1179
+ }
1167
1180
}
1168
1181
1169
1182
impl fmt:: Debug for Allocator {
Original file line number Diff line number Diff line change @@ -534,11 +534,11 @@ impl Allocator {
534
534
pub fn generate_report ( & self ) -> AllocatorReport {
535
535
let mut allocations = vec ! [ ] ;
536
536
let mut blocks = vec ! [ ] ;
537
- let mut total_reserved_bytes = 0 ;
537
+ let mut total_capacity_bytes = 0 ;
538
538
539
539
for memory_type in & self . memory_types {
540
540
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
541
- total_reserved_bytes += block. size ;
541
+ total_capacity_bytes += block. size ;
542
542
let first_allocation = allocations. len ( ) ;
543
543
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
544
544
blocks. push ( MemoryBlockReport {
@@ -554,7 +554,20 @@ impl Allocator {
554
554
allocations,
555
555
blocks,
556
556
total_allocated_bytes,
557
- total_reserved_bytes ,
557
+ total_capacity_bytes ,
558
558
}
559
559
}
560
+
561
+ /// Current total capacity of memory blocks allocated on the device, in bytes
562
+ pub fn capacity ( & self ) -> u64 {
563
+ let mut total_capacity_bytes = 0 ;
564
+
565
+ for memory_type in & self . memory_types {
566
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
567
+ total_capacity_bytes += block. size ;
568
+ }
569
+ }
570
+
571
+ total_capacity_bytes
572
+ }
560
573
}
Original file line number Diff line number Diff line change @@ -948,11 +948,11 @@ impl Allocator {
948
948
pub fn generate_report ( & self ) -> AllocatorReport {
949
949
let mut allocations = vec ! [ ] ;
950
950
let mut blocks = vec ! [ ] ;
951
- let mut total_reserved_bytes = 0 ;
951
+ let mut total_capacity_bytes = 0 ;
952
952
953
953
for memory_type in & self . memory_types {
954
954
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
955
- total_reserved_bytes += block. size ;
955
+ total_capacity_bytes += block. size ;
956
956
let first_allocation = allocations. len ( ) ;
957
957
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
958
958
blocks. push ( MemoryBlockReport {
@@ -968,9 +968,22 @@ impl Allocator {
968
968
allocations,
969
969
blocks,
970
970
total_allocated_bytes,
971
- total_reserved_bytes ,
971
+ total_capacity_bytes ,
972
972
}
973
973
}
974
+
975
+ /// Current total capacity of memory blocks allocated on the device, in bytes
976
+ pub fn capacity ( & self ) -> u64 {
977
+ let mut total_capacity_bytes = 0 ;
978
+
979
+ for memory_type in & self . memory_types {
980
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
981
+ total_capacity_bytes += block. size ;
982
+ }
983
+ }
984
+
985
+ total_capacity_bytes
986
+ }
974
987
}
975
988
976
989
impl Drop for Allocator {
You can’t perform that action at this time.
0 commit comments