This talk answers an age-old question: is garbage collection faster/slower/the same speed as malloc/free? We introduce oracular memory management, an approach that lets us measure unaltered Java programs as if they used malloc and free. The result: a good GC can match the performance of a good allocator, but it takes 5X more space. If physical memory is tight, however, conventional garbage collectors suffer an order-of-magnitude performance penalty.
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
1. Quantifying the Performance of Garbage Collection vs. Explicit Memory Management Matthew Hertz Canisius College Emery Berger University of Massachusetts Amherst
2.
3.
4.
5.
6.
7.
8.
9.
10.
11. Comparing Memory Managers BDW Collector Node v = malloc(sizeof(Node)); v->data= malloc(sizeof(NodeData)); memcpy(v->data, old->data, sizeof(NodeData)); free(old->data); v->next = old->next; v->next->prev = v; v->prev = old->prev; v->prev->next = v; free(old); Using GC in C/C++ is easy: