Skip to content

Commit

Permalink
test: fix unstable TestMemoryLeak
Browse files Browse the repository at this point in the history
  • Loading branch information
lance6716 committed Sep 17, 2021
1 parent b839744 commit a9982b8
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 @@ -5677,13 +5677,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 a9982b8

Please sign in to comment.