There appear to be several related leaks present:
- DatabaseHolder::getOrCreate() allocates a new Database object and stores this pointer in _paths[path][dbname]. Although Database::closeDatabase() removes these entries, there doesn't seem to be any logic to remove entries for a database that is created but not written to.
- When we getOrCreate() a db that's never used, the global mmfiles set is updated with a MongoFile* that has no file name. There is a comment in MongoFile::destroyed() which indicates this function should be called when a derived class is destroyed. However, ~MongoMMF() doesn't appear to be called for a database which is not written to. Note that ~MongoMMF() calls MongoMMF::close(), which calls MemoryMappedFile::close(), which finally calls MongoFile::destroy(). ~MongoMMF() is called from a few places; notably ~MongoDataFile(), ~NamespaceIndex(), and the journal recovery code.
- There are additional leaks that have not yet been identified, but can be reproduced with the repro script. The script not only causes a leak when the unused databases are 'accessed', but also a continuously increasing leak while mongod remains alive. The leak rate is about 2mb per minute when the attached script is reduced to only execute 100 iterations.
*Also, possibly worth noting, DataFileSync must iterate over all unique unwritten database names.
- is related to
-
SERVER-2498 small memory leak when closing a database
-
- Closed
-