From fcafac053fab462fe4f3cc6aae8a53bebf6656aa Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 28 Dec 2015 11:23:06 -0800 Subject: [PATCH] Fix memory leak in ColumnFamilyTest.WriteStall* Summary: ColumnFamilyTest.WriteStallSingleColumnFamily and ColumnFamilyTest.WriteStallTwoColumnFamilies didn't clean up test state cleanly, causing memory leak. Fix it. Test Plan: Run the two tests in valgrind and make sure they now pass. Reviewers: yhchiang, anthony, rven, kradhakrishnan, IslamAbdelRahman Reviewed By: IslamAbdelRahman Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D52347 --- db/column_family_test.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 1e5d5fd799..ba048e64ed 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -63,6 +63,8 @@ class ColumnFamilyTest : public testing::Test { } ~ColumnFamilyTest() { + Close(); + Destroy(); delete env_; } @@ -133,13 +135,7 @@ class ColumnFamilyTest : public testing::Test { } void Destroy() { - for (auto h : handles_) { - delete h; - } - handles_.clear(); - names_.clear(); - delete db_; - db_ = nullptr; + Close(); ASSERT_OK(DestroyDB(dbname_, Options(db_options_, column_family_options_))); } @@ -2311,7 +2307,6 @@ TEST_F(ColumnFamilyTest, WriteStallSingleColumnFamily) { ASSERT_TRUE(dbfull()->TEST_write_controler().NeedsDelay()); ASSERT_EQ(kBaseRate / 1.2, dbfull()->TEST_write_controler().delayed_write_rate()); - Close(); } TEST_F(ColumnFamilyTest, WriteStallTwoColumnFamilies) {