@@ -224,10 +224,10 @@ func TestMemoryLeakScenarios(t *testing.T) {
224
224
run : func (t * testing.T ) {
225
225
t .Helper ()
226
226
// Ensure that releasing caches frees memory.
227
- getAlloc := func () uint64 {
227
+ getAlloc := func () int64 {
228
228
var m runtime.MemStats
229
229
runtime .ReadMemStats (& m )
230
- return m .HeapAlloc
230
+ return int64 ( m .HeapAlloc )
231
231
}
232
232
233
233
runtime .GC ()
@@ -260,7 +260,7 @@ func TestMemoryLeakScenarios(t *testing.T) {
260
260
}
261
261
runtime .GC ()
262
262
// Wait to allow GC to complete.
263
- time .Sleep (5 * time .Second )
263
+ time .Sleep (1 * time .Second )
264
264
265
265
allocAfterRelease := getAlloc ()
266
266
@@ -609,15 +609,15 @@ func TestMemoryMetrics(t *testing.T) {
609
609
runtime .GC ()
610
610
611
611
// Wait a moment to allow GC to complete.
612
- time .Sleep (5 * time .Second )
612
+ time .Sleep (1 * time .Second )
613
613
614
614
runtime .ReadMemStats (& mAfter )
615
615
t .Logf ("Mallocs: before=%d, after=%d, diff=%d" , mBefore .Mallocs , mAfter .Mallocs , mAfter .Mallocs - mBefore .Mallocs )
616
616
t .Logf ("Frees: before=%d, after=%d, diff=%d" , mBefore .Frees , mAfter .Frees , mAfter .Frees - mBefore .Frees )
617
617
618
618
// Use original acceptable threshold.
619
- diff := mAfter .Mallocs - mAfter .Frees
620
- require .LessOrEqual (t , diff , uint64 (allocCount / 10 ), "Unexpected allocation leak detected" )
619
+ diff := int64 ( mAfter .Mallocs - mBefore . Mallocs ) - int64 ( mAfter .Frees - mBefore . Frees )
620
+ require .LessOrEqual (t , diff , int64 (allocCount / 10 ), "Unexpected allocation leak detected" )
621
621
}
622
622
623
623
// -----------------------------------------------------------------------------
0 commit comments