Skip to content

Commit

Permalink
Update object.md
Browse files Browse the repository at this point in the history
  • Loading branch information
quajak authored Sep 12, 2023
1 parent 9b9f04c commit 85121e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Docs/articles/Internals/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Memory Layout

Each object is allocated with a header of three ints. The first int is the type of the object, the second int is the instance type of object (normal, boxed, array etc) and the third is the size in memory.
Each object is allocated with a header of three uints. The first uint is the type of the object, the second uint is the instance type of object (normal, boxed, array etc) and the third is the size in memory.

## Garbage Collector Information

The garbage collector itself also alloctes its own header of 1 int (2 ushort). The first ushort is the allocated size of the object while the second tracks the GC information.
The garbage collector itself also alloctes its own header of 1 uint (2 ushort). The first ushort is the allocated size of the object (this includes the size of both headers) while the second tracks the GC information.
The GC information is made up of a 1bit flag (the lowest bit) used to track if the GC has hit the object during the sweep phase already and the upper 7 bits count how many static references there are to the object.

Combined in memory we have the foramt | ushort: memory size | ushort: gc info | uint: object type | uint: instance type | uint: object size | variable: object data |
Combined in memory we have the format | ushort: memory size | ushort: gc info | uint: object type | uint: instance type | uint: object size | variable: object data |

0 comments on commit 85121e7

Please sign in to comment.