1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de...
Transcript of 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de...
![Page 1: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/1.jpg)
11
Garbage CollectionGarbage Collection
Rafael Dueire Lins
Departamento de Informática
Universidade Federal de Pernambuco
![Page 2: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/2.jpg)
22
Gerenciamento EstáticoGerenciamento Estático
Mais simples. Utilizado na versão original de FORTRAN. A cada vez que um procedimento é
chamado utilizam-se as mesmas posições de memória.
Alocação decidida em tempo-de-compilação.
![Page 3: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/3.jpg)
33
Alocação Estática:Alocação Estática:
Organização da MemóriaOrganização da Memória
Programa Principal
Subrotina A
Subrotina B
Subrotina C
![Page 4: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/4.jpg)
44
Alocação Estática:Alocação Estática:Chamada a ProcedimentosChamada a Procedimentos
......z = DSucc (3) z = DSucc (3) w = DSucc (2) w = DSucc (2) ......
Programa Principal
Subrotina B
Subrotina C
DSuccDSucc(n)DSucc(n)temp1 = n + ntemp1 = n + nreturn temp1return temp1
![Page 5: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/5.jpg)
55
Alocação Estática:Alocação Estática:Chamada a ProcedimentosChamada a Procedimentos
......z = z = DSucc(3) DSucc(3) w = DSucc(2) w = DSucc(2) ......
Programa Principal
Subrotina B
Subrotina C
DSuccDSucc(3)DSucc(3)temp1 = 6temp1 = 6return temp1return temp1
![Page 6: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/6.jpg)
66
Alocação Estática:Alocação Estática:Chamada a ProcedimentosChamada a Procedimentos
......z = 6 z = 6 w = DSucc(2) w = DSucc(2) ......
Programa Principal
Subrotina B
Subrotina C
DSuccDSucc(3)DSucc(3)temp1 = 6temp1 = 6return temp1return temp1
![Page 7: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/7.jpg)
77
Alocação Estática:Alocação Estática:Chamada a ProcedimentosChamada a Procedimentos
......z = 6 z = 6 w = w = DSucc(2) DSucc(2) ......
Programa Principal
Subrotina B
Subrotina C
DSuccDSucc(2)DSucc(2)temp1 = 4temp1 = 4return temp1return temp1
![Page 8: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/8.jpg)
88
Alocação Estática:Alocação Estática:Chamada a ProcedimentosChamada a Procedimentos
......z = 6 z = 6 w = 4w = 4 ......
Programa Principal
Subrotina B
Subrotina C
DSuccDSucc(2)DSucc(2)temp1 = 4temp1 = 4return temp1return temp1
![Page 9: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/9.jpg)
99
Alocação em PilhaAlocação em Pilha
Surgiu com Algol Possibilidade de procedimentos
recursivos.
fac n = n * fac ( n - 1 ) , n > 0
= 1 , otherwise Se ProcA chama ProcB, ProcA nunca
termina antes do ProcB. Gerenciamento simples.
![Page 10: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/10.jpg)
1010
fac 2 é re-escrito como
fac 2 => 2 * fac ( 2 - 1)
=> 2 * fac 1
=> 2 * (1 * fac ( 1 - 1))
=> 2 * (1 * fac 0)
=> 2 * (1 * 1)
=> 2 * 1
=> 2
Alocação em PilhaAlocação em Pilha
![Page 11: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/11.jpg)
1111
Alocação em Pilha:Alocação em Pilha:
Organização da MemóriaOrganização da Memória
Programa Principal
Subrotina A
Subrotina B
Subrotina A
Subrotina A
Subrotina C
Memória deTrabalho
Pilha de Registrosde Ativação
![Page 12: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/12.jpg)
1212
Garbage Collection:Garbage Collection:Alocação Dinâmica de MemóriaAlocação Dinâmica de Memória
Listas: quebra da disciplina de pilha. Uma rotina chamada pode gerar uma
estrutura de dados que viva após o término da sua chamada.
IPL-5 foi a primeira linguagem a ter listas como tipo primitivos. A falta de um GC foi a causa do seu insucesso.
LISP (J.McCarthy - 1960) foi a primeira linguagem a ter GC.
![Page 13: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/13.jpg)
1313
Garbage Collection:Garbage Collection:
Organização da MemóriaOrganização da Memória
Programa Principal
Subrotina A
Memória deTrabalho
Pilha de Registrosde Ativação
Subrotina B
Subrotina C
Subrotina A
Heap
raiz 1 raiz 2
LixoLixo
![Page 14: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/14.jpg)
1414
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Heap
Free-list 1.Todas as1.Todas as célulasestãocélulasestão na free-listna free-list
![Page 15: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/15.jpg)
1515
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
HeapFree-list
1.Todas as1.Todas as célulasestãocélulasestão na free-list.na free-list.2.O processo 2.O processo do usuário do usuário usa célulasusa células
Raiz
![Page 16: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/16.jpg)
1616
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Heap
Free-list
1.Todas as1.Todas as célulasestãocélulasestão na free-list.na free-list.2.O processo 2.O processo do usuário do usuário usa células.usa células.3.A reescrita 3.A reescrita do grafodo grafo gera lixo.gera lixo.
Raiz
![Page 17: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/17.jpg)
1717
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Heap Free-list
3.A reescrita 3.A reescrita do grafodo grafo gera lixo.gera lixo.4.A free-list 4.A free-list fica vazia. fica vazia.
Raiz
![Page 18: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/18.jpg)
1818
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Heap Free-list
3.A reescrita 3.A reescrita do grafodo grafo gera lixo.gera lixo.4.A free-list 4.A free-list fica vazia. fica vazia. 5.Suspenso o5.Suspenso o processo doprocesso do usuário.usuário.6.Fá-se a 6.Fá-se a marcação.marcação.
Raiz
![Page 19: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/19.jpg)
1919
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Heap
Free-list
6.Fá-se a 6.Fá-se a marcação.marcação.7.Fá-se a 7.Fá-se a varredura,varredura, retornando retornando as células as células de lixo ade lixo a free-list.free-list.8.Retoma-se o8.Retoma-se o processo doprocesso do usúariousúario
Raiz
![Page 20: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/20.jpg)
2020
Garbage Collection:Garbage Collection:
Mark-Scan (J.McCarthy 1960)Mark-Scan (J.McCarthy 1960)
Tempo de suspensão do processo do usuário:
Grafo_em_uso + Tamanho_da_Heap Imprevisibilidade do tempo de
suspensão. Necessita de 1-bit para a marcação.
![Page 21: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/21.jpg)
2121
Reference Counting (Collins 1960)Reference Counting (Collins 1960)
Desenvolvido para LISP. Evita a suspensão do processo de
usuário. Efetuado em pequenos passos
intercalados com as transformações ao grafo.
Exige a inclusão de um contador por célula.
![Page 22: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/22.jpg)
2222
Reference Counting (Collins 1960)Reference Counting (Collins 1960) NEW: tira uma célula da free-list e conecta-a ao
grafo.
1
2
1
1
1
1
1
Free-listFree-list
RootRoot
A A
New(A.esq)New(A.esq)
BB
CC
![Page 23: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/23.jpg)
2323
Reference Counting (Collins 1960)Reference Counting (Collins 1960) NEW: tira uma célula da free-list e conecta-a ao
grafo.
1
2
1
1
1
1
1
Free-listFree-list
RootRoot
A A
New(A.esq)New(A.esq)
BB
CC
![Page 24: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/24.jpg)
2424
Reference Counting (Collins 1960)Reference Counting (Collins 1960) COPY: copia um ponteiro.
11
1
1
1
Free-listFree-list
1
2
RootRoot
A A
Copy(C.dir, A->B)Copy(C.dir, A->B)
BB
CC
![Page 25: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/25.jpg)
2525
Reference Counting (Collins 1960)Reference Counting (Collins 1960) COPY: copia um ponteiro.
12
1
1
1
Free-listFree-list
1
2
RootRoot
A A
Copy(C.dir, A->B)Copy(C.dir, A->B)
BB
CC
![Page 26: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/26.jpg)
2626
Reference Counting (Collins 1960)Reference Counting (Collins 1960) DELETE: retira um ponteiro.
11
2
1
1
Free-listFree-list
1
2
RootRoot
A A
Delete(A->B)Delete(A->B)
BB
CC
![Page 27: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/27.jpg)
2727
Reference Counting (Collins 1960)Reference Counting (Collins 1960) DELETE: retira um ponteiro.
11
2
1
1
Free-listFree-list
1
2
RootRoot
A A
Delete(A->B);Delete(A->B);Delete(Sons_B)Delete(Sons_B)
BB
CC
![Page 28: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/28.jpg)
2828
Reference Counting (Collins 1960)Reference Counting (Collins 1960) DELETE: retira um ponteiro.
11
1
1
1
Free-listFree-list
1
2
RootRoot
A A
Delete(A->B);Delete(A->B);Delete(Sons_B);Delete(Sons_B);Free(B).Free(B).
BB
CC
![Page 29: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/29.jpg)
2929
Cyclic Reference Counting Cyclic Reference Counting McBeth 1963McBeth 1963
Delete(Root->A)Delete(Root->A)2
1
RootRootA A
BB
Deleção de ponteiro a cíclo:
![Page 30: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/30.jpg)
3030
Cyclic Reference Counting Cyclic Reference Counting McBeth 1963McBeth 1963
Space-leak.
Delete(Root->A)Delete(Root->A)1
1
RootRootA A
BB
![Page 31: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/31.jpg)
3131
Cyclic Reference Counting Cyclic Reference Counting Brownbridge 1985Brownbridge 1985
Algoritmo errado!!!!
2 2
RootRoot
A A BB
2
CC
![Page 32: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/32.jpg)
3232
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Algoritmo geral!!
2 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)
![Page 33: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/33.jpg)
3333
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Age em RF > 1 (sharing)
1 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)
![Page 34: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/34.jpg)
3434
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Mark-Scan local
0 0
RootRoot
A A BB
1
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(A)Scan_green(A)
![Page 35: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/35.jpg)
3535
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Busca referências externas.
0 0
RootRoot
A A BB
1
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(A)Scan_green(A)
![Page 36: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/36.jpg)
3636
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Encontrada referência externa.
0 0
RootRoot
A A BB
1
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(A)Scan_green(A)
![Page 37: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/37.jpg)
3737
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Sub-grafo em uso.
0 0
RootRoot
A A BB
1
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(C)Scan_green(C)
![Page 38: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/38.jpg)
3838
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Referências atualizadas.
0 1
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(C)Scan_green(C)
![Page 39: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/39.jpg)
3939
Cyclic Reference Counting Cyclic Reference Counting Martinez-Wachenchauzer-LinsMartinez-Wachenchauzer-Lins Busca de lixo reciclável!
1 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)Mark_red(A)Mark_red(A)Scan_green(A)Scan_green(A)Collect_blue(A)Collect_blue(A)
Publicado em:Publicado em:Information Processing Letters 1990Information Processing Letters 1990
![Page 40: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/40.jpg)
4040
Lazy Cyclic Reference Counting Lazy Cyclic Reference Counting
LinsLins Mark-Scan postergado.
2 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)
![Page 41: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/41.jpg)
4141
Lazy Cyclic Reference Counting Lazy Cyclic Reference Counting
LinsLins Mark-Scan postergado.
1 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)
PilhaPilha
Publicado em:Publicado em:Information Processing Letters 1992Information Processing Letters 1992
![Page 42: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/42.jpg)
4242
Lazy Cyclic Reference Counting Lazy Cyclic Reference Counting
LinsLins Mark-Scan só é chamado se necessário!!
1 2
RootRoot
A A BB
2
CC
Delete(Root->A)Delete(Root->A)
PilhaPilha
![Page 43: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/43.jpg)
4343
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
A Heap é dividida em dois semi-espaços de igual tamanho.
Quando o semi-espaço em uso fica esgotado cópia-se o grafo-em-uso para o outro semi-espaço deixando o lixo para trás.
![Page 44: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/44.jpg)
4444
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
heap_1 heap_2
hp hp
raiz
![Page 45: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/45.jpg)
4545
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
heap_1 heap_2 hp hp
raiz
![Page 46: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/46.jpg)
4646
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
heap_1 heap_2
hp hp
raiz
![Page 47: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/47.jpg)
4747
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
heap_1 heap_2
hp hp
raiz
![Page 48: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/48.jpg)
4848
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
A cópia é recursiva. Há suspensão do processo de
usuário. Eficiente em máquinas com memória
virtual. Não necessita de espaço extra na
célula para marcação.
![Page 49: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/49.jpg)
4949
Garbage Collection:Garbage Collection:
Cópia (Fenichel-Yochelson 1969)Cópia (Fenichel-Yochelson 1969)
Complexidade computacional proporcional ao grafo-em-uso.
Degrada com a ocupância. Compacta os dados sem custo extra. Adequado para células de tamanho
variável.
![Page 50: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/50.jpg)
5050
Garbage Collection:Garbage Collection:
Cópia (Cheney 1970)Cópia (Cheney 1970)
Algoritmo mais amplamente usado.Algoritmo mais amplamente usado.
Não utiliza recursividade ou qualquer Não utiliza recursividade ou qualquer
outra estrutura de dados extra para outra estrutura de dados extra para
“lembrar” o caminho da cópia.“lembrar” o caminho da cópia.
Utiliza dois apontadores.Utiliza dois apontadores.
![Page 51: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/51.jpg)
5151
Garbage Collection:Garbage Collection:
Cópia (Cheney 1970)Cópia (Cheney 1970)
heap_1
heap_2
hp hp
raiz
cp cp
![Page 52: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/52.jpg)
5252
Garbage Collection:Garbage Collection:
Cópia (Cheney 1970)Cópia (Cheney 1970)
heap_1
heap_2
hp hp
raiz
cp cp
![Page 53: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/53.jpg)
5353
Garbage Collection:Garbage Collection:
Cópia (Cheney 1970)Cópia (Cheney 1970)
heap_1
heap_2
hp hp
raiz
cp cp
![Page 54: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/54.jpg)
5454
Garbage Collection:Garbage Collection:
CópiaCópia O algoritmo de Fenichel-Yochelson Fenichel-Yochelson faz
uma varredura no grafo em profundidade (depth-firstdepth-first).
O algoritmo de CheneyCheney varre o grafo breadth-firstbreadth-first.
Experimentalmente encontra-se que a varredura depth-firstdepth-first traz maior localidadelocalidade entre as células.
Há versões de Cheney depth-first.Há versões de Cheney depth-first.
![Page 55: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/55.jpg)
5555
Garbage Collection:Garbage Collection:
Cópia Generacional.Cópia Generacional.
Otimiza o algoritmo de cópia.cópia.
Células novas morrem cedo.
Células velhas vivem muito.
Segrega as células por idade:
várias heaps utilizadas.
Evidência experimental.
![Page 56: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/56.jpg)
5656
Garbage Collection:Garbage Collection:
Cópia Generacional.Cópia Generacional.
Heap 2
Raiz
Heap 1
Heap 0
CelulasCelulasVelhasVelhas
CelulasCelulasNovasNovas
![Page 57: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/57.jpg)
5757
Garbage Collection:Garbage Collection:
Cópia Generacional.Cópia Generacional.
Minor Garbage Collection:– Heaps mais novas.Heaps mais novas.– Mais freqüênte.Mais freqüênte.
Major Garbage Collection:– Equivalente ao algoritmo original de cópia.– Heap mais velha.
Problema do algoritmo: ponteiros intergeneracionais sobretudo ponteiros intergeneracionais sobretudo
célula_mais_nova -> célula_mais_velhacélula_mais_nova -> célula_mais_velha
![Page 58: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/58.jpg)
5858
Parallel Garbage Collection:Parallel Garbage Collection:
Cópia - Appel-Ellis-Li (1988)Cópia - Appel-Ellis-Li (1988) Baseado em BakerBaker. Usa informação do Sistema Operacional
para bloquear páginas de memória. Faltando espaço:Faltando espaço:
Suspende todos os threads do mutador.Suspende todos os threads do mutador. O coletor varre os objetos ainda não O coletor varre os objetos ainda não
varridos.varridos.
![Page 59: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/59.jpg)
5959
Parallel Garbage Collection:Parallel Garbage Collection:
Cópia - Appel-Ellis-Li (1988)Cópia - Appel-Ellis-Li (1988)
Faltando espaço:Faltando espaço: Troca os semi-espaços.Troca os semi-espaços. Copia os objetos acessíveis para Copia os objetos acessíveis para to-to-
spacespace.. Proteje as páginas ainda não Proteje as páginas ainda não
copiadas.copiadas. Re-inicia os threads de mutadores.Re-inicia os threads de mutadores.
Algoritmo eficiente.
![Page 60: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/60.jpg)
6060
![Page 61: 1 Garbage Collection Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco.](https://reader035.fdocumentos.tips/reader035/viewer/2022062418/552fc16d497959413d8ec91c/html5/thumbnails/61.jpg)
6161