-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.go
42 lines (35 loc) · 964 Bytes
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package alloc
import (
"context"
"github.com/Inspirate789/alloc/internal/generation"
)
const (
arenaSignalsQueueLen = 10
startHeapSize = 4
startHeapTarget = 15
)
var mainHypervisor *hypervisor
func init() {
ctx, cancel := context.WithCancel(context.Background())
arenaSignals := make(chan struct{}, arenaSignalsQueueLen)
mainHypervisor = &hypervisor{
gcCtx: ctx,
gcCancel: cancel,
arenaSignals: arenaSignals,
gcState: gcState{
lastCollectedGenerations: -1,
curHeapSize: startHeapSize,
heapTarget: startHeapTarget,
},
mem: memory{
movingGenerations: []*generation.Generation{
generation.NewGeneration(arenaSignals), // young
generation.NewGeneration(arenaSignals), // middle
generation.NewGeneration(arenaSignals), // old
},
largeObjectGeneration: generation.NewGeneration(arenaSignals),
},
}
Debugger.arenasAllocated.Store(3)
go mainHypervisor.run()
}