fix(flushall): Decommit memory after releasing tables. (#2691)

In the fiber we used to call `mi_heap_collect()` when we're done
deleting items. But since that fiber captures a `vector` of intrusive
pointers to `DbTable`s, it can't free all memory used by the tables
themselves.

A local test shows that this fix helps almost entirely: when occupying a
5gb DB, `FLUSHALL` will reduce RSS by 4.7gb, leaving 300mb still used. A
follow up `MEMORY DECOMMIT` *will* indeed remove these 300mb, but I'm
still not sure why they are not released immediately. Still looking...

Addresses (1) of #2690
This commit is contained in:
Shahar Mike 2024-03-05 15:45:13 +02:00 committed by GitHub
parent 30ce250ab2
commit 35b0ab101e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -764,6 +764,7 @@ void DbSlice::FlushDbIndexes(const std::vector<DbIndex>& indexes) {
db_ptr.reset();
}
}
flush_db_arr.clear();
mi_heap_collect(ServerState::tlocal()->data_heap(), true);
};