[*] Fix heap leak -> TryRelease was never called once count hit zero

This commit is contained in:
Reece Wilson 2022-01-18 19:42:32 +00:00
parent 413d3968ad
commit 9065d95851
2 changed files with 18 additions and 4 deletions

View File

@ -85,6 +85,7 @@ namespace Aurora::Memory
AuSPtr<Heap> GetSelfReference() override;
void TryRelease();
void DecrementUsers();
void RequestTermination();
private:
@ -211,22 +212,35 @@ namespace Aurora::Memory
{
if (buffer == nullptr) return;
o1heapFree(heap_, buffer);
count_--;
DecrementUsers();
}
void InternalHeap::DecrementUsers()
{
if (--count_ == 0)
{
AU_LOCK_GUARD(this->mutex_);
TryRelease();
}
}
void InternalHeap::TryRelease()
{
if (!isDangling_) return;
if (!isDangling_)
{
return;
}
if (count_ == 0)
{
delete this;
return;
}
}
void InternalHeap::RequestTermination()
{
AU_LOCK_GUARD(this->mutex_);
if (count_)
{
LogWarn("Heap life was less than its allocations, waiting for final free");

View File

@ -239,7 +239,7 @@ namespace Aurora::Time
}
else
{
tm.tm_isdst = -1; // out of the 2 crts i've bothered checked, out of 3, this is legal
tm.tm_isdst = -1; // out of the 2 crts i've bothered to check, out of 3, this is legal
timet = mktime(&tm);
}