@@ -6,7 +6,6 @@ package compat
66import (
77 "bytes"
88 "fmt"
9- "github.com/google/pprof/profile"
109 "io"
1110 "runtime"
1211 "runtime/pprof"
@@ -16,6 +15,7 @@ import (
1615 "testing"
1716 "time"
1817
18+ "github.com/google/pprof/profile"
1919 "github.com/grafana/pyroscope-go/godeltaprof"
2020 "github.com/stretchr/testify/require"
2121)
@@ -60,7 +60,8 @@ func TestGenericsShape(t *testing.T) {
6060 runtime .MemProfileRate = prev
6161 }()
6262
63- _ = genericAllocFunc [int ](239 )
63+ it := genericAllocFunc [int ](239 )
64+ escape (it )
6465
6566 runtime .GC ()
6667
@@ -233,10 +234,11 @@ func TestGenericsHashKeyInPprofBuilder(t *testing.T) {
233234 runtime .MemProfileRate = previousRate
234235 }()
235236 for _ , sz := range []int {128 , 256 } {
236- genericAllocFunc [uint32 ](sz / 4 )
237+ _ = genericAllocFunc [uint32 ](sz / 4 )
237238 }
238239 for _ , sz := range []int {32 , 64 } {
239- genericAllocFunc [uint64 ](sz / 8 )
240+ it := genericAllocFunc [uint64 ](sz / 8 )
241+ escape (it )
240242 }
241243
242244 runtime .GC ()
@@ -349,3 +351,10 @@ func WriteHeapProfile(w io.Writer) error {
349351 })
350352 return dh .Profile (w )
351353}
354+
355+ // make sure a is on the heap
356+ // https://go-review.googlesource.com/c/go/+/649035
357+ // https://go-review.googlesource.com/c/go/+/653856
358+ func escape (a any ) {
359+ fmt .Println (a )
360+ }
0 commit comments