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 @@ -61,8 +61,8 @@ pub struct AllocatorReport {
61
61
pub blocks : Vec < MemoryBlockReport > ,
62
62
/// Sum of the memory used by all allocations, in bytes.
63
63
pub total_allocated_bytes : u64 ,
64
- /// Sum of the memory reserved by all memory blocks including unallocated regions, in bytes.
65
- pub total_reserved_bytes : u64 ,
64
+ /// Sum of the memory capacity of all memory blocks including unallocated regions, in bytes.
65
+ pub total_capacity_bytes : u64 ,
66
66
}
67
67
68
68
impl fmt:: Debug for AllocationReport {
@@ -90,7 +90,7 @@ impl fmt::Debug for AllocatorReport {
90
90
& std:: format_args!(
91
91
"{} / {}" ,
92
92
fmt_bytes( self . total_allocated_bytes) ,
93
- fmt_bytes( self . total_reserved_bytes )
93
+ fmt_bytes( self . total_capacity_bytes )
94
94
) ,
95
95
)
96
96
. field ( "blocks" , & self . blocks . len ( ) )
Original file line number Diff line number Diff line change @@ -1126,11 +1126,11 @@ impl Allocator {
1126
1126
pub fn generate_report ( & self ) -> AllocatorReport {
1127
1127
let mut allocations = vec ! [ ] ;
1128
1128
let mut blocks = vec ! [ ] ;
1129
- let mut total_reserved_bytes = 0 ;
1129
+ let mut total_capacity_bytes = 0 ;
1130
1130
1131
1131
for memory_type in & self . memory_types {
1132
1132
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
1133
- total_reserved_bytes += block. size ;
1133
+ total_capacity_bytes += block. size ;
1134
1134
let first_allocation = allocations. len ( ) ;
1135
1135
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
1136
1136
blocks. push ( MemoryBlockReport {
@@ -1146,9 +1146,22 @@ impl Allocator {
1146
1146
allocations,
1147
1147
blocks,
1148
1148
total_allocated_bytes,
1149
- total_reserved_bytes ,
1149
+ total_capacity_bytes ,
1150
1150
}
1151
1151
}
1152
+
1153
+ /// Current total capacity of memory blocks allocated on the device, in bytes
1154
+ pub fn capacity ( & self ) -> u64 {
1155
+ let mut total_capacity_bytes = 0 ;
1156
+
1157
+ for memory_type in & self . memory_types {
1158
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
1159
+ total_capacity_bytes += block. size ;
1160
+ }
1161
+ }
1162
+
1163
+ total_capacity_bytes
1164
+ }
1152
1165
}
1153
1166
1154
1167
impl fmt:: Debug for Allocator {
Original file line number Diff line number Diff line change @@ -518,11 +518,11 @@ impl Allocator {
518
518
pub fn generate_report ( & self ) -> AllocatorReport {
519
519
let mut allocations = vec ! [ ] ;
520
520
let mut blocks = vec ! [ ] ;
521
- let mut total_reserved_bytes = 0 ;
521
+ let mut total_capacity_bytes = 0 ;
522
522
523
523
for memory_type in & self . memory_types {
524
524
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
525
- total_reserved_bytes += block. size ;
525
+ total_capacity_bytes += block. size ;
526
526
let first_allocation = allocations. len ( ) ;
527
527
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
528
528
blocks. push ( MemoryBlockReport {
@@ -538,7 +538,20 @@ impl Allocator {
538
538
allocations,
539
539
blocks,
540
540
total_allocated_bytes,
541
- total_reserved_bytes ,
541
+ total_capacity_bytes ,
542
542
}
543
543
}
544
+
545
+ /// Current total capacity of memory blocks allocated on the device, in bytes
546
+ pub fn capacity ( & self ) -> u64 {
547
+ let mut total_capacity_bytes = 0 ;
548
+
549
+ for memory_type in & self . memory_types {
550
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
551
+ total_capacity_bytes += block. size ;
552
+ }
553
+ }
554
+
555
+ total_capacity_bytes
556
+ }
544
557
}
Original file line number Diff line number Diff line change @@ -934,11 +934,11 @@ impl Allocator {
934
934
pub fn generate_report ( & self ) -> AllocatorReport {
935
935
let mut allocations = vec ! [ ] ;
936
936
let mut blocks = vec ! [ ] ;
937
- let mut total_reserved_bytes = 0 ;
937
+ let mut total_capacity_bytes = 0 ;
938
938
939
939
for memory_type in & self . memory_types {
940
940
for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
941
- total_reserved_bytes += block. size ;
941
+ total_capacity_bytes += block. size ;
942
942
let first_allocation = allocations. len ( ) ;
943
943
allocations. extend ( block. sub_allocator . report_allocations ( ) ) ;
944
944
blocks. push ( MemoryBlockReport {
@@ -954,9 +954,22 @@ impl Allocator {
954
954
allocations,
955
955
blocks,
956
956
total_allocated_bytes,
957
- total_reserved_bytes ,
957
+ total_capacity_bytes ,
958
958
}
959
959
}
960
+
961
+ /// Current total capacity of memory blocks allocated on the device, in bytes
962
+ pub fn capacity ( & self ) -> u64 {
963
+ let mut total_capacity_bytes = 0 ;
964
+
965
+ for memory_type in & self . memory_types {
966
+ for block in memory_type. memory_blocks . iter ( ) . flatten ( ) {
967
+ total_capacity_bytes += block. size ;
968
+ }
969
+ }
970
+
971
+ total_capacity_bytes
972
+ }
960
973
}
961
974
962
975
impl Drop for Allocator {
You can’t perform that action at this time.
0 commit comments