[*] Fix heap leak -> TryRelease was never called once count hit zero
This commit is contained in:
parent
413d3968ad
commit
9065d95851
@ -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");
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user