Skip to content

Commit 6f0651c

Browse files
committed
tmp : Introduce intentional memory retention for regression testing
This commit allocates a large 300MB slice at startup and ensures it is not garbage collected by keeping a reference alive. Signed-off-by: Rohan Kumar <[email protected]>
1 parent 2024c54 commit 6f0651c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ func init() {
9494
}
9595

9696
func main() {
97+
// Allocate memory once at start
98+
dummy := make([]byte, 300*1024*1024)
99+
for i := range dummy {
100+
dummy[i] = byte(i % 255)
101+
}
102+
103+
// Prevent GC from reclaiming it
104+
_ = dummy
97105
var metricsAddr string
98106
var enableLeaderElection bool
99107
flag.StringVar(&metricsAddr, "metrics-addr", ":8443", "The address the metric endpoint binds to.")

0 commit comments

Comments
 (0)