Skip to content

Question regarding GC notification! #132

Discussion options

You must be logged in to vote

Ok, I got it. But GC doesn't change the layout of array elements. Address of each array element is aligned in memory according to its size. For ref types (class), each element is always aligned to sizeof(nint), i.e. 4 bytes on 32-bit machine or 8 bytes on 64-bit machine. As a result, if address of array[0] is some X, then address of n-th element will be X+sizeof(nint)*n.

To detect heap compaction, you can do the following:

await GCNotification.HeapCompaction().WaitAsync();

ahh thx mate good to know

Replies: 9 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@sakno
Comment options

@CodingMadness
Comment options

@sakno
Comment options

@CodingMadness
Comment options

@sakno
Comment options

Answer selected by CodingMadness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #131 on November 19, 2022 08:12.