24:
742:
732:
722:
712:
702:
144:
The forwarding pointer (sometimes called a "broken heart") is used only during the garbage collection process; when a reference to an object already in to-space (thus having a forwarding pointer in from-space) is found, the reference can be updated quickly simply by updating its pointer to match the
199:
The algorithm moves any white objects (equivalent to objects in the from-space without forwarding pointers) to the gray set by copying them to the to-space. Objects that are between the scanning pointer and the free-space pointer on the to-space area are members of the gray set still to be scanned.
136:
The algorithm needs no stack and only two pointers outside of the from-space and to-space: a pointer to the beginning of free space in the to-space, and a pointer to the next word in to-space that needs to be examined. The data between the two pointers represents work remaining for it to do (those
167:
collect() = swap(fromspace, tospace) allocPtr = fromspace scanPtr = fromspace -- scan every root you've got ForEach root in the stack -- or elsewhere root = copy(root) EndForEach -- scan objects in the to-space (including objects added by this loop) While
99:
is divided into two equal halves, only one of which is in use at any one time. Garbage collection is performed by copying live objects from one semispace (the from-space) to the other (the to-space), which then becomes the new heap. The entire old heap is then discarded in one piece. It is an
113:
If the object has not yet been moved to the to-space, this is done by creating an identical copy in the to-space, and then replacing the from-space version with a forwarding pointer to the to-space copy. Then update the object reference to refer to the new version in
168:
scanPtr < allocPtr ForEach reference r from o (pointed to by scanPtr) r = copy(r) EndForEach scanPtr = scanPtr + o.size() -- points to the next object in the to-space, if any EndWhile
163:
allocate(n) = If allocPtr + n > fromspace + N/2 collect() EndIf If allocPtr + n > fromspace + N/2 fail “insufficient memory” EndIf o = allocPtr allocPtr = allocPtr + n return o
171:
copy(o) = If o has no forwarding address o' = allocPtr allocPtr = allocPtr + size(o) copy the contents of o to o' forwarding-address(o) = o' EndIf return forwarding-address(o)
196:
garbage collector. The first member of the gray set is the stack itself. Objects referenced on the stack are copied into the to-space, which contains members of the black and gray sets.
682:
343:
110:
Object references on the stack are checked. One of the two following actions is taken for each object reference that points to an object in from-space:
391:
200:
Objects below the scanning pointer belong to the black set. Objects are moved to the black set by simply moving the scanning pointer over them.
735:
539:
363:
766:
725:
745:
84:
160:
initialize() = tospace = N/2 fromspace = 0 allocPtr = fromspace scanPtr = whatever -- only used during collection
67:
45:
562:
336:
687:
117:
If the object has already been moved to the to-space, simply update the reference from the forwarding pointer in from-space.
148:
Because the strategy is to exhaust all live references, and then all references in referenced objects, this is known as a
547:
385:
524:
582:
705:
592:
572:
425:
329:
315:
193:
92:
651:
511:
38:
32:
715:
577:
552:
458:
529:
481:
379:
49:
203:
When the scanning pointer reaches the free-space pointer, the gray set is empty, and the algorithm ends.
284:
435:
677:
661:
587:
271:
236:
453:
352:
96:
133:
Once all to-space references have been examined and updated, garbage collection is complete.
630:
625:
468:
261:
226:
184:
garbage collector, which was published a year earlier by R.R. Fenichel and J.C. Yochelson.
620:
519:
635:
602:
597:
443:
402:
760:
612:
415:
410:
88:
275:
240:
656:
420:
309:
567:
448:
266:
249:
231:
214:
501:
496:
486:
476:
491:
129:, and performs one of the above two actions on the referenced objects.
321:
325:
250:"A LISP garbage-collector for virtual-memory computer systems"
17:
318:- Android uses a variant of the semi-space garbage collector.
364:
Memory management as a function of an operating system
127:
in the objects that have been migrated to the to-space
125:
The garbage collector examines all object references
100:
improvement on the previous stop-and-copy technique.
670:
644:
611:
538:
510:
467:
434:
401:
372:
95:in computer software systems. In this scheme, the
103:Cheney's algorithm reclaims items as follows:
337:
311:Understanding Android Runtime (Google I/O'19)
248:Fenichel, R.R.; Yochelson, Jerome C. (1969).
8:
683:International Symposium on Memory Management
344:
330:
322:
215:"A Nonrecursive List Compacting Algorithm"
141:in the tri-color terminology, see later).
265:
230:
68:Learn how and when to remove this message
152:list copying garbage collection scheme.
31:This article includes a list of general
192:Cheney's algorithm is an example of a
7:
188:Equivalence to tri-color abstraction
392:Input–output memory management unit
37:it lacks sufficient corresponding
14:
741:
740:
731:
730:
721:
720:
711:
710:
701:
700:
22:
563:Concurrent mark sweep collector
285:"Garbage Collection Algorithms"
108:Object references on the stack.
688:Region-based memory management
213:Cheney, C.J. (November 1970).
1:
292:Garbage Collection Algorithms
180:Cheney based his work on the
736:Memory management algorithms
548:Automatic Reference Counting
386:Translation lookaside buffer
83:, first described in a 1970
767:Automatic memory management
726:Automatic memory management
525:C dynamic memory allocation
87:paper by C.J. Cheney, is a
783:
746:Memory management software
593:Tracing garbage collection
426:Virtual memory compression
93:tracing garbage collection
696:
359:
254:Communications of the ACM
219:Communications of the ACM
520:Static memory allocation
512:Manual memory management
123:Objects in the to-space.
578:Garbage-first collector
553:Boehm garbage collector
459:x86 memory segmentation
52:more precise citations.
583:Mark–compact algorithm
380:Memory management unit
267:10.1145/363269.363280
232:10.1145/362790.362798
530:new and delete (C++)
283:Byers, Rick (2007).
145:forwarding pointer.
436:Memory segmentation
678:Automatic variable
662:Unreachable memory
588:Reference counting
558:Cheney's algorithm
540:Garbage collection
81:Cheney's algorithm
754:
753:
706:Memory management
454:Virtual 8086 mode
353:Memory management
194:tri-color marking
78:
77:
70:
774:
744:
743:
734:
733:
724:
723:
714:
713:
704:
703:
631:Dangling pointer
626:Buffer over-read
598:Strong reference
469:Memory allocator
346:
339:
332:
323:
312:
299:
289:
279:
269:
244:
234:
156:Sample algorithm
73:
66:
62:
59:
53:
48:this article by
39:inline citations
26:
25:
18:
782:
781:
777:
776:
775:
773:
772:
771:
757:
756:
755:
750:
692:
666:
640:
621:Buffer overflow
607:
534:
506:
463:
430:
397:
368:
355:
350:
310:
306:
287:
282:
260:(11): 611–612.
247:
225:(11): 677–678.
212:
209:
190:
178:
173:
169:
165:
161:
158:
74:
63:
57:
54:
44:Please help to
43:
27:
23:
12:
11:
5:
780:
778:
770:
769:
759:
758:
752:
751:
749:
748:
738:
728:
718:
716:Virtual memory
708:
697:
694:
693:
691:
690:
685:
680:
674:
672:
668:
667:
665:
664:
659:
654:
648:
646:
642:
641:
639:
638:
636:Stack overflow
633:
628:
623:
617:
615:
609:
608:
606:
605:
603:Weak reference
600:
595:
590:
585:
580:
575:
570:
565:
560:
555:
550:
544:
542:
536:
535:
533:
532:
527:
522:
516:
514:
508:
507:
505:
504:
499:
494:
489:
484:
479:
473:
471:
465:
464:
462:
461:
456:
451:
446:
444:Protected mode
440:
438:
432:
431:
429:
428:
423:
418:
413:
407:
405:
403:Virtual memory
399:
398:
396:
395:
389:
383:
376:
374:
370:
369:
367:
366:
360:
357:
356:
351:
349:
348:
341:
334:
326:
320:
319:
305:
304:External links
302:
301:
300:
280:
245:
208:
205:
189:
186:
177:
174:
170:
166:
162:
159:
157:
154:
131:
130:
120:
119:
118:
115:
76:
75:
30:
28:
21:
13:
10:
9:
6:
4:
3:
2:
779:
768:
765:
764:
762:
747:
739:
737:
729:
727:
719:
717:
709:
707:
699:
698:
695:
689:
686:
684:
681:
679:
676:
675:
673:
669:
663:
660:
658:
655:
653:
652:Fragmentation
650:
649:
647:
643:
637:
634:
632:
629:
627:
624:
622:
619:
618:
616:
614:
613:Memory safety
610:
604:
601:
599:
596:
594:
591:
589:
586:
584:
581:
579:
576:
574:
571:
569:
566:
564:
561:
559:
556:
554:
551:
549:
546:
545:
543:
541:
537:
531:
528:
526:
523:
521:
518:
517:
515:
513:
509:
503:
500:
498:
495:
493:
490:
488:
485:
483:
480:
478:
475:
474:
472:
470:
466:
460:
457:
455:
452:
450:
447:
445:
442:
441:
439:
437:
433:
427:
424:
422:
419:
417:
416:Memory paging
414:
412:
411:Demand paging
409:
408:
406:
404:
400:
393:
390:
387:
384:
381:
378:
377:
375:
371:
365:
362:
361:
358:
354:
347:
342:
340:
335:
333:
328:
327:
324:
317:
313:
308:
307:
303:
297:
293:
286:
281:
277:
273:
268:
263:
259:
255:
251:
246:
242:
238:
233:
228:
224:
220:
216:
211:
210:
206:
204:
201:
197:
195:
187:
185:
183:
175:
155:
153:
151:
150:breadth-first
146:
142:
140:
134:
128:
124:
121:
116:
112:
111:
109:
106:
105:
104:
101:
98:
94:
90:
89:stop and copy
86:
82:
72:
69:
61:
51:
47:
41:
40:
34:
29:
20:
19:
16:
557:
295:
291:
257:
253:
222:
218:
202:
198:
191:
181:
179:
149:
147:
143:
138:
137:objects are
135:
132:
126:
122:
107:
102:
80:
79:
64:
55:
36:
15:
657:Memory leak
50:introducing
421:Page table
298:(11): 3–4.
207:References
91:method of
58:April 2014
33:references
568:Finalizer
449:Real mode
182:semispace
176:Semispace
114:to-space.
761:Category
502:ptmalloc
497:mimalloc
487:jemalloc
477:dlmalloc
373:Hardware
276:36616954
241:36538112
573:Garbage
492:libumem
394:(IOMMU)
316:YouTube
46:improve
645:Issues
274:
239:
35:, but
671:Other
482:Hoard
388:(TLB)
382:(MMU)
288:(PDF)
272:S2CID
237:S2CID
139:gray
97:heap
314:on
262:doi
227:doi
85:ACM
763::
296:12
294:.
290:.
270:.
258:12
256:.
252:.
235:.
223:13
221:.
217:.
345:e
338:t
331:v
278:.
264::
243:.
229::
71:)
65:(
60:)
56:(
42:.
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.