@@ -76,7 +76,8 @@ def garbage_collect
76
76
end
77
77
78
78
def self . stat ( option = nil )
79
- time , count , minor_count , major_count , unknown_count , committed , used , memory_pool_names , memory_pool_info = Primitive . gc_stat ( )
79
+ time , count , minor_count , major_count , unknown_count , heap , memory_pool_names , memory_pool_info = Primitive . gc_stat ( )
80
+ used , committed , init , max = heap
80
81
81
82
# Initialize stat for statistics that come from memory pools, and populate it with some final stats
82
83
stat = {
@@ -85,45 +86,45 @@ def self.stat(option = nil)
85
86
minor_gc_count : minor_count ,
86
87
major_gc_count : major_count ,
87
88
unknown_count : unknown_count , # if nonzero, major or minor count needs to be updated for this GC case
88
- committed : 0 ,
89
- init : 0 ,
90
- max : 0 ,
91
- used : 0 ,
89
+ heap_available_slots : committed ,
90
+ heap_live_slots : used ,
91
+ heap_free_slots : committed - used ,
92
+ used : used ,
93
+ committed : committed ,
94
+ init : init ,
95
+ max : max ,
96
+ peak_used : 0 ,
92
97
peak_committed : 0 ,
93
98
peak_init : 0 ,
94
99
peak_max : 0 ,
95
- peak_used : 0 ,
100
+ last_used : 0 ,
96
101
last_committed : 0 ,
97
102
last_init : 0 ,
98
103
last_max : 0 ,
99
- last_used : 0 ,
100
- heap_available_slots : committed , # should be the same as the calculated committed
101
- heap_live_slots : used , # should be the same as the calculated used
102
- heap_free_slots : committed - used ,
103
104
}
104
105
105
106
memory_pool_names . each_with_index do |memory_pool_name , i |
106
107
# Populate memory pool specific stats
107
108
info = memory_pool_info [ i ]
108
109
if info
109
110
stat [ memory_pool_name ] = data = {
110
- committed : info [ 0 ] ,
111
- init : info [ 1 ] ,
112
- max : info [ 2 ] ,
113
- used : info [ 3 ] ,
114
- peak_committed : info [ 4 ] ,
115
- peak_init : info [ 5 ] ,
116
- peak_max : info [ 6 ] ,
117
- peak_used : info [ 7 ] ,
118
- last_committed : info [ 8 ] ,
119
- last_init : info [ 9 ] ,
120
- last_max : info [ 10 ] ,
121
- last_used : info [ 11 ] ,
111
+ used : info [ 0 ] ,
112
+ committed : info [ 1 ] ,
113
+ init : info [ 2 ] ,
114
+ max : info [ 3 ] ,
115
+ peak_used : info [ 4 ] ,
116
+ peak_committed : info [ 5 ] ,
117
+ peak_init : info [ 6 ] ,
118
+ peak_max : info [ 7 ] ,
119
+ last_used : info [ 8 ] ,
120
+ last_committed : info [ 9 ] ,
121
+ last_init : info [ 10 ] ,
122
+ last_max : info [ 11 ] ,
122
123
}
123
124
124
- # Calculate stats across memory pools
125
+ # Calculate stats across memory pools for peak_/last_ (we already know the values for current usage)
125
126
data . each_pair do |key , value |
126
- stat [ key ] += value
127
+ stat [ key ] += value if key . start_with? ( 'peak_' , 'last_' )
127
128
end
128
129
end
129
130
end
0 commit comments