Skip to content

Commit

Permalink
test: fix unstable TestMemoryLeak (#28111)
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 authored Sep 28, 2021
1 parent 74b3294 commit bd5f742
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5723,13 +5723,14 @@ func (s *testTiDBAsLibrary) TestMemoryLeak(c *C) {
runtime.ReadMemStats(&memStat)
oldHeapInUse := memStat.HeapInuse

for i := 0; i < 10; i++ {
for i := 0; i < 20; i++ {
initAndCloseTiDB()
}

runtime.GC()
runtime.ReadMemStats(&memStat)
c.Assert(memStat.HeapInuse-oldHeapInUse, Less, uint64(150*units.MiB))
// before the fix, initAndCloseTiDB for 20 times will cost 900 MB memory, so we test for a quite loose upper bound.
c.Assert(memStat.HeapInuse-oldHeapInUse, Less, uint64(300*units.MiB))
}

func (s *testSessionSuite) TestTiDBReadStaleness(c *C) {
Expand Down

0 comments on commit bd5f742

Please sign in to comment.