/* * Return unused memory to the system if possible. */ static void trimHeaps() { HS_BOILERPLATE(); HeapSource *hs = gHs; size_t heapBytes = 0; for (size_t i = 0; i < hs->numHeaps; i++) { Heap *heap = &hs->heaps[i]; /* Return the wilderness chunk to the system. */ mspace_trim(heap->msp, 0); /* Return any whole free pages to the system. */ mspace_walk_free_pages(heap->msp, releasePagesInRange, &heapBytes); } /* Same for the native heap. */ dlmalloc_trim(0); size_t nativeBytes = 0; dlmalloc_walk_free_pages(releasePagesInRange, &nativeBytes); LOGD_HEAP("madvised %zd (GC) + %zd (native) = %zd total bytes", heapBytes, nativeBytes, heapBytes + nativeBytes); }
TCustomFileSystem::~TCustomFileSystem() { #ifdef USE_DLMALLOC dlmalloc_trim(0); // 64 * 1024); #endif }
void DLAllocator::CollectMemory() { dlmalloc_trim(0); }
int qemu_instrumented_malloc_trim(size_t pad) { return dlmalloc_trim(pad); }