[K/N] Fix ExtraObjectData not being collected ^KT-63423

This commit is contained in:
Alexander Shabalin
2024-01-15 10:39:40 +01:00
committed by Space Cloud
parent 76898ddb0f
commit d2cf4548f6
2 changed files with 11 additions and 1 deletions
@@ -78,5 +78,13 @@ size_t alloc::allocatedBytes() noexcept {
void alloc::destroyExtraObjectData(mm::ExtraObjectData& extraObject) noexcept {
extraObject.ReleaseAssociatedObject();
extraObject.setFlag(mm::ExtraObjectData::FLAGS_FINALIZED);
if (extraObject.GetBaseObject()) {
// If there's an object attached to this extra object, the next
// GC sweep will have to resolve this cycle.
extraObject.setFlag(mm::ExtraObjectData::FLAGS_FINALIZED);
} else {
// If there's no object attached to this extra object, the next
// GC sweep will just collect this extra object.
extraObject.setFlag(mm::ExtraObjectData::FLAGS_SWEEPABLE);
}
}
@@ -78,9 +78,11 @@ bool SweepObject(uint8_t* object, FinalizerQueue& finalizerQueue, gc::GCHandle::
bool SweepExtraObject(mm::ExtraObjectData* extraObject, gc::GCHandle::GCSweepExtraObjectsScope& gcHandle) noexcept {
if (extraObject->getFlag(mm::ExtraObjectData::FLAGS_SWEEPABLE)) {
gcHandle.addSweptObject();
CustomAllocDebug("SweepExtraObject(%p): can be reclaimed", extraObject);
return false;
}
gcHandle.addKeptObject(sizeof(mm::ExtraObjectData));
CustomAllocDebug("SweepExtraObject(%p): is still needed", extraObject);
return true;
}