24
24
25
25
umf_memory_pool_ops_t * umfJemallocPoolOps (void ) { return NULL ; }
26
26
27
- umf_result_t
28
- umfJemallocPoolParamsCreate (umf_jemalloc_pool_params_handle_t * hParams ) {
29
- (void )hParams ; // unused
30
- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
31
- }
32
-
33
- umf_result_t
34
- umfJemallocPoolParamsDestroy (umf_jemalloc_pool_params_handle_t hParams ) {
35
- (void )hParams ; // unused
36
- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
37
- }
38
-
39
- umf_result_t
40
- umfJemallocPoolParamsSetKeepAllMemory (umf_jemalloc_pool_params_handle_t hParams ,
41
- bool keepAllMemory ) {
42
- (void )hParams ; // unused
43
- (void )keepAllMemory ; // unused
44
- return UMF_RESULT_ERROR_NOT_SUPPORTED ;
45
- }
46
-
47
27
#else
48
28
49
29
#include <jemalloc/jemalloc.h>
@@ -53,16 +33,8 @@ umfJemallocPoolParamsSetKeepAllMemory(umf_jemalloc_pool_params_handle_t hParams,
53
33
typedef struct jemalloc_memory_pool_t {
54
34
umf_memory_provider_handle_t provider ;
55
35
unsigned int arena_index ; // index of jemalloc arena
56
- // set to true if umfMemoryProviderFree() should never be called
57
- bool disable_provider_free ;
58
36
} jemalloc_memory_pool_t ;
59
37
60
- // Configuration of Jemalloc Pool
61
- typedef struct umf_jemalloc_pool_params_t {
62
- /// Set to true if umfMemoryProviderFree() should never be called.
63
- bool disable_provider_free ;
64
- } umf_jemalloc_pool_params_t ;
65
-
66
38
static __TLS umf_result_t TLS_last_allocation_error ;
67
39
68
40
static jemalloc_memory_pool_t * pool_by_arena_index [MALLCTL_ARENAS_ALL ];
@@ -75,52 +47,6 @@ static jemalloc_memory_pool_t *get_pool_by_arena_index(unsigned arena_ind) {
75
47
return pool_by_arena_index [arena_ind ];
76
48
}
77
49
78
- umf_result_t
79
- umfJemallocPoolParamsCreate (umf_jemalloc_pool_params_handle_t * hParams ) {
80
- if (!hParams ) {
81
- LOG_ERR ("jemalloc pool params handle is NULL" );
82
- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
83
- }
84
-
85
- umf_jemalloc_pool_params_t * params_data =
86
- umf_ba_global_alloc (sizeof (* params_data ));
87
- if (!params_data ) {
88
- LOG_ERR ("cannot allocate memory for jemalloc poolparams" );
89
- return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
90
- }
91
-
92
- params_data -> disable_provider_free = false;
93
-
94
- * hParams = (umf_jemalloc_pool_params_handle_t )params_data ;
95
-
96
- return UMF_RESULT_SUCCESS ;
97
- }
98
-
99
- umf_result_t
100
- umfJemallocPoolParamsDestroy (umf_jemalloc_pool_params_handle_t hParams ) {
101
- if (!hParams ) {
102
- LOG_ERR ("jemalloc pool params handle is NULL" );
103
- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
104
- }
105
-
106
- umf_ba_global_free (hParams );
107
-
108
- return UMF_RESULT_SUCCESS ;
109
- }
110
-
111
- umf_result_t
112
- umfJemallocPoolParamsSetKeepAllMemory (umf_jemalloc_pool_params_handle_t hParams ,
113
- bool keepAllMemory ) {
114
- if (!hParams ) {
115
- LOG_ERR ("jemalloc pool params handle is NULL" );
116
- return UMF_RESULT_ERROR_INVALID_ARGUMENT ;
117
- }
118
-
119
- hParams -> disable_provider_free = keepAllMemory ;
120
-
121
- return UMF_RESULT_SUCCESS ;
122
- }
123
-
124
50
// arena_extent_alloc - an extent allocation function conforms to the extent_alloc_t type and upon
125
51
// success returns a pointer to size bytes of mapped memory on behalf of arena arena_ind such that
126
52
// the extent's base address is a multiple of alignment, as well as setting *zero to indicate
@@ -150,9 +76,7 @@ static void *arena_extent_alloc(extent_hooks_t *extent_hooks, void *new_addr,
150
76
}
151
77
152
78
if (new_addr != NULL && ptr != new_addr ) {
153
- if (!pool -> disable_provider_free ) {
154
- umfMemoryProviderFree (pool -> provider , ptr , size );
155
- }
79
+ umfMemoryProviderFree (pool -> provider , ptr , size );
156
80
return NULL ;
157
81
}
158
82
@@ -186,10 +110,6 @@ static void arena_extent_destroy(extent_hooks_t *extent_hooks, void *addr,
186
110
187
111
jemalloc_memory_pool_t * pool = get_pool_by_arena_index (arena_ind );
188
112
189
- if (pool -> disable_provider_free ) {
190
- return ;
191
- }
192
-
193
113
umf_result_t ret ;
194
114
ret = umfMemoryProviderFree (pool -> provider , addr , size );
195
115
if (ret != UMF_RESULT_SUCCESS ) {
@@ -212,10 +132,6 @@ static bool arena_extent_dalloc(extent_hooks_t *extent_hooks, void *addr,
212
132
213
133
jemalloc_memory_pool_t * pool = get_pool_by_arena_index (arena_ind );
214
134
215
- if (pool -> disable_provider_free ) {
216
- return true; // opt-out from deallocation
217
- }
218
-
219
135
umf_result_t ret ;
220
136
ret = umfMemoryProviderFree (pool -> provider , addr , size );
221
137
if (ret != UMF_RESULT_SUCCESS ) {
@@ -466,12 +382,10 @@ static void *op_aligned_alloc(void *pool, size_t size, size_t alignment) {
466
382
467
383
static umf_result_t op_initialize (umf_memory_provider_handle_t provider ,
468
384
void * params , void * * out_pool ) {
385
+ (void )params ; // unused
469
386
assert (provider );
470
387
assert (out_pool );
471
388
472
- umf_jemalloc_pool_params_handle_t je_params =
473
- (umf_jemalloc_pool_params_handle_t )params ;
474
-
475
389
extent_hooks_t * pHooks = & arena_extent_hooks ;
476
390
size_t unsigned_size = sizeof (unsigned );
477
391
int err ;
@@ -484,12 +398,6 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
484
398
485
399
pool -> provider = provider ;
486
400
487
- if (je_params ) {
488
- pool -> disable_provider_free = je_params -> disable_provider_free ;
489
- } else {
490
- pool -> disable_provider_free = false;
491
- }
492
-
493
401
unsigned arena_index ;
494
402
err = je_mallctl ("arenas.create" , (void * )& arena_index , & unsigned_size ,
495
403
NULL , 0 );
0 commit comments