@@ -271,8 +271,6 @@ static umf_result_t umfMemoryTrackerRemove(umf_memory_tracker_handle_t hTracker,
271
271
parent_value -> n_children -- ;
272
272
}
273
273
274
- umf_ba_free (hTracker -> alloc_info_allocator , value );
275
-
276
274
return UMF_RESULT_SUCCESS ;
277
275
}
278
276
@@ -339,8 +337,6 @@ umfMemoryTrackerRemoveIpcSegment(umf_memory_tracker_handle_t hTracker,
339
337
(void * )hTracker , ptr , v -> size , (void * )v -> provider ,
340
338
(void * )v -> ipc_cache_value );
341
339
342
- umf_ba_free (hTracker -> ipc_info_allocator , value );
343
-
344
340
return UMF_RESULT_SUCCESS ;
345
341
}
346
342
@@ -664,8 +660,6 @@ static umf_result_t trackingAllocationMerge(void *hProvider, void *lowPtr,
664
660
lowLevel , lowPtr , lowValue -> n_children , highPtr ,
665
661
highValue -> n_children , totalSize );
666
662
667
- umf_ba_free (provider -> hTracker -> alloc_info_allocator , highValue );
668
-
669
663
return UMF_RESULT_SUCCESS ;
670
664
671
665
err_fatal :
@@ -1116,6 +1110,15 @@ umf_memory_provider_ops_t UMF_TRACKING_MEMORY_PROVIDER_OPS = {
1116
1110
.ipc .open_ipc_handle = trackingOpenIpcHandle ,
1117
1111
.ipc .close_ipc_handle = trackingCloseIpcHandle };
1118
1112
1113
+ /*
1114
+ static void free_ipc_cache_value(void *unused, void *ipc_cache_value) {
1115
+ (void)unused;
1116
+ if (ipc_cache_value) {
1117
+ umf_ba_global_free(ipc_cache_value);
1118
+ }
1119
+ }
1120
+ */
1121
+
1119
1122
umf_result_t umfTrackingMemoryProviderCreate (
1120
1123
umf_memory_provider_handle_t hUpstream , umf_memory_pool_handle_t hPool ,
1121
1124
umf_memory_provider_handle_t * hTrackingProvider ) {
@@ -1128,6 +1131,7 @@ umf_result_t umfTrackingMemoryProviderCreate(
1128
1131
return UMF_RESULT_ERROR_UNKNOWN ;
1129
1132
}
1130
1133
params .pool = hPool ;
1134
+ // params.ipcCache = critnib_new(free_ipc_cache_value, NULL);
1131
1135
params .ipcCache = critnib_new (NULL , NULL );
1132
1136
if (!params .ipcCache ) {
1133
1137
LOG_ERR ("failed to create IPC cache" );
@@ -1156,6 +1160,18 @@ void umfTrackingMemoryProviderGetUpstreamProvider(
1156
1160
* hUpstream = p -> hUpstream ;
1157
1161
}
1158
1162
1163
+ static void free_leaf (void * leaf_allocator , void * ptr ) {
1164
+ if (ptr ) {
1165
+ umf_ba_free (leaf_allocator , ptr );
1166
+ }
1167
+ }
1168
+
1169
+ static void free_ipc_segment (void * ipc_info_allocator , void * ptr ) {
1170
+ if (ptr ) {
1171
+ umf_ba_free (ipc_info_allocator , ptr );
1172
+ }
1173
+ }
1174
+
1159
1175
umf_memory_tracker_handle_t umfMemoryTrackerCreate (void ) {
1160
1176
umf_memory_tracker_handle_t handle =
1161
1177
umf_ba_global_alloc (sizeof (struct umf_memory_tracker_t ));
@@ -1180,7 +1196,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1180
1196
1181
1197
int i ;
1182
1198
for (i = 0 ; i < MAX_LEVELS_OF_ALLOC_SEGMENT_MAP ; i ++ ) {
1183
- handle -> alloc_segments_map [i ] = critnib_new (NULL , NULL );
1199
+ handle -> alloc_segments_map [i ] =
1200
+ critnib_new (free_leaf , alloc_info_allocator );
1184
1201
if (!handle -> alloc_segments_map [i ]) {
1185
1202
goto err_destroy_alloc_segments_map ;
1186
1203
}
@@ -1192,7 +1209,8 @@ umf_memory_tracker_handle_t umfMemoryTrackerCreate(void) {
1192
1209
goto err_destroy_alloc_segments_map ;
1193
1210
}
1194
1211
1195
- handle -> ipc_segments_map = critnib_new (NULL , NULL );
1212
+ handle -> ipc_segments_map =
1213
+ critnib_new (free_ipc_segment , handle -> ipc_info_allocator );
1196
1214
if (!handle -> ipc_segments_map ) {
1197
1215
goto err_destroy_ipc_info_allocator ;
1198
1216
}
0 commit comments