[*] Updated to a fixed version of O(1) heap (partial update from 2022'Sept was incomplete)
This commit is contained in:
parent
0d6d073b85
commit
bab44d097a
@ -98,9 +98,6 @@ namespace Aurora::Memory
|
||||
void UpdateStats() override;
|
||||
|
||||
private:
|
||||
|
||||
AuThreadPrimitives::Mutex mutex_;
|
||||
|
||||
O1HeapInstance *heap_ {};
|
||||
int count_ {};
|
||||
bool isDangling_ {};
|
||||
@ -136,7 +133,6 @@ namespace Aurora::Memory
|
||||
{
|
||||
if (this->heap_)
|
||||
{
|
||||
o1HeapReleaseCpp(this->heap_);// ->~O1HeapInstance(); // TODO: make free func
|
||||
this->heap_ = nullptr;
|
||||
}
|
||||
|
||||
@ -168,19 +164,7 @@ namespace Aurora::Memory
|
||||
this->ownsMemory_ = true;
|
||||
}
|
||||
|
||||
this->heap_ = o1heapInit(this->base_, length,
|
||||
[this](const O1HeapInstance *const handle) -> void
|
||||
{
|
||||
SysAssertDbg(this->mutex_, "missing mutex");
|
||||
this->mutex_->Lock();
|
||||
},
|
||||
[this](const O1HeapInstance *const handle) -> void
|
||||
{
|
||||
SysAssertDbg(this->mutex_, "missing mutex");
|
||||
this->mutex_->Unlock();
|
||||
}
|
||||
);
|
||||
|
||||
this->heap_ = o1heapInit(this->base_, length);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -335,16 +319,16 @@ namespace Aurora::Memory
|
||||
|
||||
void InternalHeap::RequestTermination()
|
||||
{
|
||||
this->mutex_->Lock();
|
||||
|
||||
if (this->count_)
|
||||
if (AuAtomicLoad(&this->count_))
|
||||
{
|
||||
SysPushErrorMemory("Heap life was less than its allocations, waiting for final free");
|
||||
SysPushErrorMemory("Reporting using mayday!");
|
||||
|
||||
// Write a crash dump for later review, and do not panic.
|
||||
// We just have a leak with no sign of corruption
|
||||
Telemetry::Mayday();
|
||||
|
||||
this->isDangling_ = true;
|
||||
this->mutex_->Unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user