Bhainistíonn Ruby cuimhne go huathoibríoch trí bailitheoir dramhaíola (GC) a fhosclaíonn oibreacha nach bhfuil tagairt orthu a thuilleadh. Úsáideann Ruby nua-aimseartha (MRI) bailitheoir géineatach, ioncrannach mark-and-sweep le comhbhogadh. Cabhraíonn thuiscint air seo le feidhmíocht agus diagnóis fadhbanna cuimhne a dhéanamh i bhfeidhmchláir fhadtéarmacha.
Bailiú dramhaíola uathoibríoch
Ruby allocates objects on the heap; the GC reclaims those that are no longer REACHABLE
(referenced). You never free memory manually.
Modern MRI GC characteristics:
✓ Mark-and-sweep — marks reachable objects (from roots), sweeps unreachable ones
✓ Generational (since Ruby 2.1) — new objects collected often, old ones rarely
(based on "most objects die young")
✓ Incremental — spreads GC work to reduce pause times
✓ Compacting (GC.compact, Ruby 2.7+) — reduces memory fragmentation
