diff --git a/src/runtime/mfixalloc.go b/src/runtime/mfixalloc.go index 293c16b38b1..78ca861f65c 100644 --- a/src/runtime/mfixalloc.go +++ b/src/runtime/mfixalloc.go @@ -31,6 +31,7 @@ type fixalloc struct { list *mlink chunk uintptr // use uintptr instead of unsafe.Pointer to avoid write barriers nchunk uint32 + nalloc uint32 inuse uintptr // in-use bytes now stat *sysMemStat zero bool // zero allocations @@ -56,6 +57,7 @@ func (f *fixalloc) init(size uintptr, first func(arg, p unsafe.Pointer), arg uns f.list = nil f.chunk = 0 f.nchunk = 0 + f.nalloc = uint32(_FixAllocChunk / f.size * f.size) f.inuse = 0 f.stat = stat f.zero = true @@ -77,8 +79,8 @@ func (f *fixalloc) alloc() unsafe.Pointer { return v } if uintptr(f.nchunk) < f.size { - f.chunk = uintptr(persistentalloc(_FixAllocChunk, 0, f.stat)) - f.nchunk = _FixAllocChunk + f.chunk = uintptr(persistentalloc(uintptr(f.nalloc), 0, f.stat)) + f.nchunk = f.nalloc } v := unsafe.Pointer(f.chunk)