1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 15:44:57 +00:00

Kernel: Break retain cycle between Inode and VMObject.

There's no need for an Inode to keep its corresponding VMObject alive.
Obviously there are huge benefits to keeping a filesystem cache,
but leaking everything is hardly the right strategy. :^)
This commit is contained in:
Andreas Kling 2019-02-08 16:40:48 +01:00
parent e1be5a468d
commit d4ba155711
4 changed files with 9 additions and 9 deletions

View file

@ -667,7 +667,7 @@ RetainPtr<VMObject> VMObject::create_file_backed(RetainPtr<Inode>&& inode)
if (inode->vmo())
return static_cast<VMObject*>(inode->vmo());
auto vmo = adopt(*new VMObject(move(inode)));
vmo->inode()->set_vmo(vmo.ptr());
vmo->inode()->set_vmo(*vmo);
return vmo;
}
@ -732,10 +732,8 @@ VMObject::VMObject(RetainPtr<Inode>&& inode)
VMObject::~VMObject()
{
if (m_inode) {
if (m_inode)
ASSERT(m_inode->vmo() == this);
m_inode->set_vmo(nullptr);
}
MM.unregister_vmo(*this);
}