diff options
Diffstat (limited to 'src/runtime/malloc_test.go')
| -rw-r--r-- | src/runtime/malloc_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go index f0e73baea5..b8278bb4bc 100644 --- a/src/runtime/malloc_test.go +++ b/src/runtime/malloc_test.go @@ -82,6 +82,23 @@ func TestStringConcatenationAllocs(t *testing.T) { } } +func TestTinyAlloc(t *testing.T) { + const N = 16 + var v [N]unsafe.Pointer + for i := range v { + v[i] = unsafe.Pointer(new(byte)) + } + + chunks := make(map[uintptr]bool, N) + for _, p := range v { + chunks[uintptr(p)&^7] = true + } + + if len(chunks) == N { + t.Fatal("no bytes allocated within the same 8-byte chunk") + } +} + var mallocSink uintptr func BenchmarkMalloc8(b *testing.B) { |
