Download - Garbage collection no Ruby
![Page 1: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/1.jpg)
Garbage Collection Ruby
![Page 2: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/2.jpg)
Gerenciamento manual de memória
![Page 3: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/3.jpg)
Objeto 01 Objeto 02
![Page 4: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/4.jpg)
Desalocar manualmente
![Page 5: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/5.jpg)
Objeto 01 Objeto 02
![Page 6: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/6.jpg)
Objeto 01
![Page 7: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/7.jpg)
Mas imagine o seguinte cenário
![Page 8: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/8.jpg)
Objeto 01 Objeto 02
![Page 9: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/9.jpg)
Objeto 01 Objeto 02
![Page 10: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/10.jpg)
Referência para um objeto que não existe mais
![Page 11: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/11.jpg)
Seu sistema pode quebrar
![Page 12: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/12.jpg)
Ou pior…
![Page 13: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/13.jpg)
Ele pode gerar resultados incorretos
![Page 14: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/14.jpg)
Outras preocupações além do domínio da aplicação
![Page 15: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/15.jpg)
Entender como os módulos que você utiliza gerenciam sua memória
![Page 16: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/16.jpg)
Lauro Caetano @laurocaetano
![Page 17: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/17.jpg)
![Page 18: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/18.jpg)
![Page 19: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/19.jpg)
Open Source
![Page 20: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/20.jpg)
![Page 21: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/21.jpg)
![Page 22: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/22.jpg)
![Page 23: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/23.jpg)
Rails
![Page 24: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/24.jpg)
Rails core team
![Page 25: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/25.jpg)
O que é Garbage Collection e como ele foi evoluindo a cada nova versão do Ruby
![Page 26: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/26.jpg)
Agenda• O que é Garbage Collection
• Garbage Collection no Ruby - Mark and sweep
• Desvantagens do Mark and Sweep
• Evolução
• Lazy Sweep - Ruby 1.9
• Bitmap Mark - Ruby 2.0
• Generational Garbage Collection - Ruby 2.1
![Page 27: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/27.jpg)
O que é Garbage Collection?
![Page 28: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/28.jpg)
Gerenciamento dinâmico automático de memória
![Page 29: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/29.jpg)
3 Responsabilidades
![Page 30: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/30.jpg)
1. Alocar espaço para novos objetos
![Page 31: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/31.jpg)
2. Identificar os objetos ainda vivos
![Page 32: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/32.jpg)
3. Recuperar o espaço ocupado por objetos
mortos
![Page 33: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/33.jpg)
Garbage Collection no Ruby
![Page 34: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/34.jpg)
Ruby ainda utiliza o mesmo algoritmo que foi inventado a mais
de 50 anos por John MacCarthy
![Page 35: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/35.jpg)
Mark-Sweep
![Page 36: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/36.jpg)
Free List
![Page 37: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/37.jpg)
![Page 38: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/38.jpg)
![Page 39: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/39.jpg)
![Page 40: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/40.jpg)
![Page 41: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/41.jpg)
![Page 42: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/42.jpg)
Hora de limpar o Heap
![Page 43: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/43.jpg)
Stop the world
![Page 44: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/44.jpg)
Percorre todos os objetos do heap e marca os que
ainda estão vivos
![Page 45: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/45.jpg)
![Page 46: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/46.jpg)
![Page 47: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/47.jpg)
![Page 48: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/48.jpg)
![Page 49: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/49.jpg)
![Page 50: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/50.jpg)
Varre novamente o heap, mas agora em busca dos objetos não marcados e os remove do heap
![Page 51: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/51.jpg)
![Page 52: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/52.jpg)
![Page 53: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/53.jpg)
![Page 54: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/54.jpg)
![Page 55: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/55.jpg)
![Page 56: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/56.jpg)
![Page 57: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/57.jpg)
![Page 58: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/58.jpg)
![Page 59: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/59.jpg)
Volta a executar o seu programa
![Page 60: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/60.jpg)
Vamos ao código
![Page 61: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/61.jpg)
!
1 def new! 2 ref = allocate! 3 ! 4 if ref.nil?! 5 collect! 6 ! 7 if ref.nil?! 8 raise "Out of memory"! 9 end!10 end!11 end!!!
![Page 62: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/62.jpg)
12 !13 def collect!14 mark_from_roots!15 sweep(@heap_start, @heap_end)!16 end!17 !!!
![Page 63: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/63.jpg)
17 !18 def mark_from_roots!19 initialize(worklist)!20 !21 @roots.each do |fld|!22 ref = fld!23 if !ref.nil? && !marked?(ref)!24 set_marked(ref)!25 mark!26 end!27 end!28 end!29
![Page 64: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/64.jpg)
!
32 !33 def mark!34 while(@worklist.any?)!35 ref = remove(worklist)!36 !37 pointers(ref).each do |fld|!38 child = fld!39 !40 if !child.nil? && !marked?(child)!41 set_marked(child)!42 add(@worklist, child)!43 end!44 end!45 end!46 end!47
![Page 65: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/65.jpg)
47 !48 def sweep(heap_start, heap_end)!49 scan = start!50 !51 while (scan < heap_end)!52 if marked?(scan)!53 unset_marked(scan)!54 else!55 free(scan)!56 end!57 !58 scan = next_object(scan)!59 end!60 end
![Page 66: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/66.jpg)
Desvantagens do Mark and sweep
![Page 67: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/67.jpg)
Fazer Full GC toda hora que o heap está cheio não
parece uma boa ideia
![Page 68: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/68.jpg)
Stop the world
![Page 69: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/69.jpg)
Mark and sweep é proporcional ao tamanho
do heap
![Page 70: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/70.jpg)
Evolução
![Page 71: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/71.jpg)
Lazy Sweep Ruby 1.9
![Page 72: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/72.jpg)
Fazer Full GC toda hora que o heap está cheio não
parece uma boa ideia
![Page 73: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/73.jpg)
Recuperar apenas o espaço necessário para criar um novo
objeto e permitir que a aplicação continue rodando
![Page 74: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/74.jpg)
Agora o sweep não para mais o mundo todo
![Page 75: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/75.jpg)
A alocação é responsável por checar se existe
espaço disponível
![Page 76: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/76.jpg)
Caso não tenha espaço disponível, fazer Lazy Sweep
até obter o espaço necessário
![Page 77: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/77.jpg)
12 !13 def allocate(size)!14 result = remove(size)!15 !16 if result.nil?!17 lazy_sweep(size)!18 result = remove(size)!19 end!20 !21 result!22 end!23
![Page 78: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/78.jpg)
Bitmap Mark Ruby 2.0
![Page 79: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/79.jpg)
![Page 80: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/80.jpg)
Como os bits de marcação no ficavam objeto, os valores
eram sempre diferentes
![Page 81: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/81.jpg)
Para possibilitar que o Unix compartilhe valores iguais
![Page 82: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/82.jpg)
Os bits de marcação foram movidos para uma
tabela de bitmap
![Page 83: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/83.jpg)
1 1 1 1 10 0
![Page 84: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/84.jpg)
Generational Garbage Collection Ruby 2.1
![Page 85: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/85.jpg)
Mark and sweep é proporcional ao tamanho
do heap
![Page 86: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/86.jpg)
Weak generational hypothesis
![Page 87: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/87.jpg)
O coletor processa mais frequentemente objetos novos do que objetos
maduros
![Page 88: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/88.jpg)
Um objeto maduro é aquele que permanece ativo por
um algum período de tempo
![Page 89: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/89.jpg)
Enquanto um objeto novo é aquele que seu sistema
acabou de criar
![Page 90: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/90.jpg)
Geração Nova Geração Madura
![Page 91: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/91.jpg)
Quando o mark and sweep terminar, os objetos restantes serão considerados maduros
![Page 92: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/92.jpg)
Geração Nova Geração Madura
![Page 93: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/93.jpg)
Geração Nova Geração Madura
![Page 94: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/94.jpg)
Objetos maduros não serão marcados novamente
até um próximo full GC
![Page 95: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/95.jpg)
Quando o full GC ocorrer, todos os objetos passarão
pelo mark and sweep
![Page 96: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/96.jpg)
É legal entender como as coisas funcionam
![Page 98: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/98.jpg)
Bonus
![Page 99: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/99.jpg)
JRuby and Rubinius.
![Page 100: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/100.jpg)
Copying Garbage Collection
![Page 101: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/101.jpg)
Segmento de memória contínua
![Page 102: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/102.jpg)
Bump Allocation
![Page 103: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/103.jpg)
Aloca segmentos adjacentes de memória, mantendo um ponteiro
para a próxima alocação
![Page 104: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/104.jpg)
Próxima alocação
![Page 105: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/105.jpg)
Próxima alocação
![Page 106: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/106.jpg)
Próxima alocação
![Page 107: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/107.jpg)
Objetos podem ser de tamanhos diferentes
![Page 108: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/108.jpg)
A grande vantagem é que valores relacionados ficam
próximos
![Page 109: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/109.jpg)
A CPU pode cachear a região de memória que for acessada frequentemente
![Page 110: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/110.jpg)
Também utiliza o Garbage Collection Generacional
![Page 111: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/111.jpg)
Ruby 2.2
![Page 112: Garbage collection no Ruby](https://reader033.vdocuments.mx/reader033/viewer/2022052622/558e690b1a28ab0f668b4574/html5/thumbnails/112.jpg)
GC Simbolos