Skip to content

How does GC find out class implements destructor? #117242

Answered by EgorBo
voroninp asked this question in Q&A
Discussion options

You must be logged in to vote

You can access a bitflag from object's pMethodTable to see if it has a finalizer or not (obj->pMT->m_flags & 0x00100000). But I think GC doesn't query it explicitly. Instead, we register object in the finalizer queue on the allocation step. Objects with finalizers always use the slow path for allocations.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@voroninp
Comment options

@EgorBo
Comment options

EgorBo Jul 2, 2025
Collaborator

@AustinWise
Comment options

Answer selected by voroninp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants