@cryptotaxi247 / netdata-1 / commits / cbff54ac7

onewayallocator to use mallocz() instead of mmap() (#12810)

Costa Tsaousis committed May 3, 2022 at 21:29 UTC cbff54ac71f2a76d1f7e7c80d85328159857314a
1 file changed +5 -3
libnetdata/onewayalloc/onewayalloc.c
+5 -3
@@ -50,8 +50,9 @@ static OWA_PAGE *onewayalloc_create_internal(OWA_PAGE *head, size_t size_hint) {
50 // Make sure our allocations are always a multiple of the hardware page size
51 if(size % OWA_NATURAL_PAGE_SIZE) size = size + OWA_NATURAL_PAGE_SIZE - (size % OWA_NATURAL_PAGE_SIZE);
52
53 - OWA_PAGE *page = (OWA_PAGE *)netdata_mmap(NULL, size, MAP_ANONYMOUS|MAP_PRIVATE, 0);
54 - if(unlikely(!page)) fatal("Cannot allocate onewayalloc buffer of size %zu", size);
53 + // OWA_PAGE *page = (OWA_PAGE *)netdata_mmap(NULL, size, MAP_ANONYMOUS|MAP_PRIVATE, 0);
54 + // if(unlikely(!page)) fatal("Cannot allocate onewayalloc buffer of size %zu", size);
55 + OWA_PAGE *page = (OWA_PAGE *)mallocz(size);
56
57 page->size = size;
58 page->offset = natural_alignment(sizeof(OWA_PAGE));
@@ -168,6 +169,7 @@ void onewayalloc_destroy(ONEWAYALLOC *owa) {
169 while(page) {
170 OWA_PAGE *p = page;
171 page = page->next;
171 - munmap(p, p->size);
172 + // munmap(p, p->size);
173 + freez(p);
174 }
175 }