[K/N] Fix ExtraObjectData not being collected ^KT-63423
This commit is contained in:
committed by
Space Cloud
parent
76898ddb0f
commit
d2cf4548f6
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user