diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 096d444223..9d428b4c13 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -503,7 +503,21 @@ void Ext2FS::flush_writes() #endif } } + DiskBackedFS::flush_writes(); + + // Uncache Inodes that are only kept alive by the index-to-inode lookup cache. + // FIXME: It would be better to keep a capped number of Inodes around. + // The problem is that they are quite heavy objects, and use a lot of heap memory + // for their (child name lookup) and (block list) caches. + Vector unused_inodes; + for (auto& it : m_inode_cache) { + if (it.value->ref_count() != 1) + continue; + unused_inodes.append(it.key); + } + for (auto index : unused_inodes) + uncache_inode(index); } Ext2FSInode::Ext2FSInode(Ext2FS& fs, unsigned index)