void runtime_freemcache(MCache *c) { runtime_MCache_ReleaseAll(c); runtime_lock(&runtime_mheap); runtime_purgecachedstats(c); runtime_FixAlloc_Free(&runtime_mheap.cachealloc, c); runtime_unlock(&runtime_mheap); }
// Allocate a new span of npage pages from the heap // and record its size class in the HeapMap and HeapMapCache. MSpan* runtime_MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct) { MSpan *s; runtime_lock(h); runtime_purgecachedstats(m); s = MHeap_AllocLocked(h, npage, sizeclass); if(s != nil) { mstats.heap_inuse += npage<<PageShift; if(acct) { mstats.heap_objects++; mstats.heap_alloc += npage<<PageShift; } } runtime_unlock(h); return s; }
// Allocate a new span of npage pages from the heap // and record its size class in the HeapMap and HeapMapCache. MSpan* runtime_MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct, int32 zeroed) { MSpan *s; runtime_lock(h); runtime_purgecachedstats(runtime_m()->mcache); s = MHeap_AllocLocked(h, npage, sizeclass); if(s != nil) { mstats.heap_inuse += npage<<PageShift; if(acct) { mstats.heap_objects++; mstats.heap_alloc += npage<<PageShift; } } runtime_unlock(h); if(s != nil && *(uintptr*)(s->start<<PageShift) != 0 && zeroed) runtime_memclr((byte*)(s->start<<PageShift), s->npages<<PageShift); return s; }