diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index 9191b6ea6..66ade6b21 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1651,12 +1651,7 @@ Status DBImpl::TrimMemtableHistory(WriteContext* context) { for (auto& cfd : cfds) { autovector to_delete; bool trimmed = cfd->imm()->TrimHistory( - &to_delete, cfd->mem()->ApproximateMemoryUsage()); - if (!to_delete.empty()) { - for (auto m : to_delete) { - delete m; - } - } + &context->memtables_to_free_, cfd->mem()->ApproximateMemoryUsage()); if (trimmed) { context->superversion_context.NewSuperVersion(); assert(context->superversion_context.new_superversion.get() != nullptr);