When I create a new fragment or structure using make or a new call:
s := make([]int64, 10, 100)
o := new(MyStruct)
How much memory does Go take up allocating a system memory allocation call? Does it provide pre-allocation of memory so that subsequent calls do not cause new system calls?
I ask about this because I need to allocate memory often in my code. I'm not sure if I need to implement a memory allocator myself, or if I can depend on Go to do the dirty work. And if Go does the preliminary allocation of memory, can I adjust the block size for allocation?
I write experiment code in Go and run the code under strace, but I don’t understand what Go does with mmap system calls:
mmap(0xc000000000, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
munmap(0xc000000000, 65536) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7efdd1017000
mmap(0xc208000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc208000000
mmap(0xc207ff0000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc207ff0000
mmap(0xc000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7efdd1007000
mmap(NULL, 1439992, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7efdd0ea7000