1. Trang chủ
  2. » Công Nghệ Thông Tin

garbage collection algorithms for automatic dynamic memory management - richard jones

203 283 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Garbage Collection Algorithms for Automatic Dynamic Memory Management - Richard Jones
Trường học University of Example
Chuyên ngành Computer Science
Thể loại Thesis
Năm xuất bản 2023
Thành phố Sample City
Định dạng
Số trang 203
Dung lượng 13,99 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Updating pointer requires’ additional effort other than ‘extra instructions manipulate reference counts reference counting even greater marking, identifies active cells.. When marking p

Trang 6

collection

Trang 8

reference counting

Trang 12

automatic reclamation

SIMM memory

increasingly profligaté-in

operating system

single-user

personal computer,

twelve megabytes

operate optimally

storage requirements

computer programs

garbage collection

computer science community

individual papers

Applications OOPSLA conferences;.as

international workshops exclusively devoted

extended argumenton-Usenet.news

Trang 16

Static allocation

Trang 17

program fragment

Trang 20

thorough

Wilson notes

very existence

such weakly engineered

The solution

make

garbage collection

part

system rather than

mandatory requirement

the solution

Programs

with straightforward

dynamic memory requirements

cost

explicit deallocation*,

However, beware solutions

simple problems

short-term gain-may

have

longer-term

cost, Problem specifications

may make demands

garbage collection

that memory.requests

time spent serving

such requests

hard real-time programming,

Nor do-we argue

garbage collection

Garbage collection

own costs,

terms

both time

space, and

two

classic bugs

explicit storage management

dangling pointers and space Jeaks:—

moreover Taises debugging problems

that grow:

such data structures

‘surprisingly éommon’,

with

example being

[Detlefs and

Kalsow, 1995]

Such growth

often benign

programs under

exit before

simpler interfaces between software components

abstract representation

does

The most

array:

What should pop

The choice suggested

abstract representation’

the stack isto

1,6

on the following page)

pointer held

oe

Tông garbage Sollectors jdentify

live data

following pointers

the roo

we

computation, including

program stack

Unfortunately

the stack can become:

polluted

obsolete pointers:

these pointers

traced,

space leak might-ocour.-One.source

stack

frame pollution

failure

null local variables

after their last use

However,

one frame may calls

necessarily always true

Trang 23

weigh against

other

Trade-offs between

different applications

prioritise different

would stress

pause times whereas overall

would demand small upper bounds

garbage collection pauses

storage overheads

might

main concern

embedded system

Portability

collector between different architectures, compilers

application programs

significant consideration

reference counting,

tightly coupled

example tracing collectors

compare some

right questions

suggests approaches

might

profitably explored

garbage collection:

applies equally

explicit allocators

others, Experience

garbage collected systems

atomic field

By extension,

object

that contains

pointer fields will

the heap teachable from

each root

the program forms

directed graph whose nodes are the data cells and

heap abjects

References

are stored within pointer fields

heap cells

These graphs may overlap

they may

we denote

Heap

When

we are considering algorithms

for fixed-size objects,

the size

slot will usually

one object

Otherwise

the size

a slot shall

one word

‘We denote the bottom

the heap

cell

the memory address

initial word

may

may not contain pointers

refer

denote the list

refer

arbitrary fields

cell

— which

this

case,

we shall

treat

the cell

Nil

We alsa choose

count fields from

field

We

shall

use anotation

The cell also has

header

long

The children

Bach

the four fields

one word

further cells whose addresses

are

(n+2) and

Diagram

1.7 Á heap cell

Pseudo-code

We shall use

common framework

describe garbage

collection algorithms

We have!

a real programming

language

for four reaspns

First, pseudo-

code reduces clutter (such

short fragments

of code

Second,

the consequence

using

2 real programming

language

that these fragments

would

become:

very large

Third, our algorithm

fraginents

are intended

Trang 24

storage

— reference

counting, mark-sweep

how they work

later chapters more efficient ways

implementing

these methods

garbage collection

from other, active cells

roots (Collins,

ally incremental technique, distributing

overheads

memory management throughout

applications,

example,.early versions

Smalltalk object-oriented

language (Goldberg

and Robson, 1983], ThierLiSP, Mộdula=——~

program

also the method used

a file rnay-be deleted from

teacing garbage collectors

each cell

heap cells

starting point for

is usually implementes.as.a

linked list

their pointer fields, which

used exclusively

Alternatively,

ofthe cell’s user data fields may be-used

erates under

a fundamentally

— strategy

from that

Trang 25

memory management overheads

distributed throughout

Trang 26

garbage collection

TImmediate knowledge

Reference counting

Trang 28

26

THE CLASSICAL ALGORITHMS

The algorithm

more detail

New acquires

new cell from the pool and

preceding page)

reference counting algorithm

alternatives

consider these

mark-sweep

garbage collection

Updating

pointer requires’

additional

effort other than

‘extra instructions

manipulate

reference counts

reference counting

even greater

marking, identifies

active cells

second, sweep, phase returns garbage

recover sufficiently

many free cells,

A bit associated

with each

tracing from

have already

been marked

When

marking phase

simple transliteration

those

clear being unmarked,

hence must

unmarked

free (N}

else mark_bit(N)

over reference counting

that have.led

functional language Miranda [Turner, 1985].and by.conservative

garbage collectors

[Boehm

and Weiser, 1988])

Cycles

hhandied quite naturally,

other hand;

Trang 30

copy (R}

reference counting

Trang 35

His

‘THE CLASSICAL

that was similar

linearised

lists

so that the

two marking

bits

each cell, and five data were scanned twice

handle circular lists

Robert Fenichel

and Jerome Yochelson devised

chapier

for Lisp cons cells (Fenichel

and Yochelson,

scheme was

—-

eager sweep phase that visited each cell

space would not suffice

Copying

was recursive

with explicit mark-bits

field

each copied cell

the same way

forwarding

field

The best-known copying

algorithm

iterative rather than recursive

constant workspace can

1976;

Robson, 1977;

Clark, 1978;

Lee

al., 1979;

parts were each 15-bit quantities,

the tag and prefix parts each

bits

Because

the latter two bits were separated

the decrement,

they could not easily

This made the architecture unsuitable

for reference counting

ather than mark-sweep

garbage collection would

have meant

complete rewrite because

the close coupling

reference counting with

the user program

Lisp

entering labels,

ic

new copies

function definitions,

which does not generate cycles

even though his mark-sweep

method was capable

reclaiming

such structures

Reference

counting

first, though cumbersome

error-prone, reference counting technique

George Collins [Collins, 1960]

Interestingly,

described McCarthy’s mark-sweep

reference counting outperformed mark-

how closely

reference counting algorithm

collect cyclic

structures

was first noted

Harold McBeth (McBeth, 1963]

was Marvin Minsky’s garbage collector

tape storage

early days

virtual memory architectures,

Daniel Bobrow

Daniel Murphy combined

mark-sweep

primary method

garbage collection

their implementation

variant

Minsky’s copying collector

compact

heap when

necessary

[Bobrow and

Murphy, 1967]

ae

D.T

Boss’s AED Free Storage Package

used the concept

‘plex progratmming’

system generalised copying

arbitrary number

spaces;

and, whenever a.space became full,

objects were copied

different space

Similar ideas

Chapter

The generality

Ross copying

collector made

been poorly acknowledged

Wilfted Hansen

structure

which reflected

704’s assembly

The algorithm

their

enormous address spaces (potentially billions

the edr-

His elegant

space (see Chapter

General algorithms

for copying lists

Clark, 1975;

Trang 37

Overwriting

pointer typically requires a.dozen

objects, tendering reference:

language

a similar system

identify:

singly-

threaded Objééts;

Trang 38

46

REFERENCE COUNTING

Trang 41

uniquely referenced

cells

Although uniqueness information

scheme

going again

before

another garbage collection

required provided

reclaiming space

an

two-pass compacting compactor

schemes), unique references

Mark-compactcollectors

typically operate

multiple references

corrects

these references

suitable copying collector must maintain

forwarding address}

Wise’s

algorithm requires

original Tospace reference

used.as

forwarding address

Trang 42

separates intelligence

in-RCM mark-sweep

Trang 43

Internal references

programmer declares certain pointers

scheme

reclaims groups

entire group

linked through

additional pointer

fundamental drawback

Bobrow’s algorithm

Babrow’s scheme

bestif each

group

comprised

single

sirongly connected component

(SCC)

graph, thatis,

Trang 44

58

REFERENCE COUNTING

Trang 45

structure reachable

-from.@

traversed (along strong pointers

Trang 46

6

REFERENCE COUNTING

each cell

requires

reference caunt fields,

turns

that both types

Partial

Mark-Sweep

Algorithms

‘The final algorithms

chapter take

very different approach

‘Their general idea

perform three partial waversals

data structure,

place removing

contribution

pointers internal

sub-graph

~ peing traversed from

reference.counts

only reflect external pointers

counts

nodes reachable

from external pointers whilst

third phase sweeps garbage

originally invented

Christopher {Christopher,

1984]

since been

algorithm

provide dynamic storage allocation

with garbage

The primary method

reclaiming garbageis reference counting

However,

tracing collector

called periodically

reclaim nodes in‘the heap

have non-zero

reference counts’

(which may

impossible

discover accurately without

algorithms developed

Most cells

freed

reference counting

garbage cycles

Any cells

uniquely referenced:

when their count drops

deleted:

pointer [Martinez:et

1990]

Cyclic reference counting would

prohibitively expensive

shared pointer was deleted:

these traversals

some suitable point,

traps pointer writes and saves

will not

preserved”

This highlights

the difference between

reference counting with

lazy mark-sweep algorithm

and standard mark-sweep collection

The latter traverses

only

active data structure whereas,

best case, Lins’s collector traces only cyclic garbage

(although

may have

trace, unsuccessfully,

live data

well)

shall first consider Lins’s lazy algorithm

Lins

which every cell with

non-zero count

extra field

used:

black, grey, white and purple®

Intuitively, active

cells

painted black, and garbage

and free cells white, Cells visited

marking phase

visited again

Purple cells may

and ensures that only those cells

active will

traced

The control

further evidence

whether cells

will have been

deleted,

which case they will have

been returned

free-list (and possibly reused),

their pointers

will have been copied

which case they must

cells will not

purple

The only difference between Lins’s New and that

standard version shown

must decide when

collect

control set

There

also just one difference between Lins’s Update

(see Algorithm

standard

one

Both arguments

Lins’s Update must

active and hence should

removed from

done (logically)

painting

cells black

hash table

removed physically

new reference:

this

always possible

purple

Some may have been repainted black

have had their last reference deleted

Such cells will either

free-list (white)or have

Lins’s control

However black, grey, white

better with

Trang 47

“4

REFERENCE COUNTING

non-zero reférence

external references

internal pointers

Although

below implements

collect_white

traversal, following pointers,

could equally

counting algorithm

Suppose.the

pointer from root

further allocations

becomes necessary

invoke

garbage collector

graph ABCDE

gc_control_set

would simply

check whether componenis

transitive closure

Scan (S}_=

else colour(S)

Lins’s algorithm

Trang 48

66

REFERENCE COUNTING

reference counting

deleted pointer

Trang 49

object-oriented

anguages

‘smart pointers’

reference counting

provide programmers

optimising reference counting

Trang 50

Note-that.Lins’s

Trang 52

reference counting, mark-sweep

copying garbage collection

‘compare

theirrelative merits

several advantages

reference counting

structures

Although techniques

handling cycles.in a:.reference-

comparisons

cyclic reference

reference counting

primary method

teclaim cyclic

sirnctures.(e.g

Modula-2+

[DeTreville, 1990a])

Reference counting

primarily because

recycles memory instantly

Tracing collectors

active data’structures

_to:special

Trang 56

MARK-SWEEP GARBAGE COLLECTION

POINTER REVERSAL

process continues

algorithm retreats

parent node, Eventually,

another pointer-cell

Their scheme

Trang 57

86

MARK-SWEEP GARBAGE COLLECTION

typically comprise

separate bitmaps

heap For example,

atomic objects commonly account

Trang 59

90

MARK-SWEEP

GARBAGE COLLECTION

Trang 61

marking algorithms,

processing language,

Trang 63

spatial ordering

Trang 64

MARK-COMPACT

GARBAGE COLLECTION

reclaim unbounded amounts

Green,

Clark, 1979]

adjacently,

sliding compaction

spatial spread)

whether

algorithm handles objects

include:

‘Two-Finger algorithms:

Edwards {Saunders,

next page)

Heap [new]

Trang 67

106

MARK-COMPACT

GARBAGE COLLECTION

correct position

cachibreak -.—-

record could

wherever possible,

table-based methods include storing

before moving cells

Trang 68

forward, updating

Trang 69

suitable

abstract machine architectures

Trang 70

Although

compacting collector

Trang 71

discovered independently

Fernandez

David Hanson describe

(Fernandez

Hanson, 1992]

Jacques Cohen

Laurent Trilling

Trang 72

Since Cheney’s discovery

implementation,

copying collection

proved popular

implementors

Although garbage

collection technology

moved beyond

simple

stop-and-copy collection,

more sophisticated techniques,

Copying collection

other forms

automatic memory management

Like

non-incremental

tracing collector,

makes copying particularly attractive

example, Standard

Jersey (SML/NS)

typically reclaims’

eager sweep

stopcatid-copy

collection than-on

other form

tracing collection

Copying- garbage collection compacts

tactics,

unnecessary

Thirdly, compacting

non-copying Collectors, iterative copying garbage collection

further heap memory

Trang 73

118

COPYING GARBAGE COLLECTION

Trang 77

collection

Copying

garbage collection

particularly effective

active graph, visited

auxiliary stack

Trang 80

clusters objects according

mutator’s pattern

examine

how successful

collection techniques

Trang 81

evacuation mechanism

Trang 83

depth-first

Trang 86

eos sou

g payunideyy 'Áz8n†{ony ẩunnđio2 Joy uoyersossy 6661@ ‘16d Td “(661 “7 72 OS[LAA ] Ấ†[#9ƒJoTenI[ potdos aah Ammq y zy"9 0180

Trang 87

particular implementations,

Virtual memory algorithms

typically allocate

Programis written

However,

strong evidence

Trang 88

interesting properties

generational

garbage collection First,

minor collections

general, generational algorithms

Ngày đăng: 17/04/2014, 09:15

TỪ KHÓA LIÊN QUAN

w