Method and apparatus for decreasing object copying by a generational, copying garbage collector
AssigneeSun Microsystems, Inc.
InventorsDavid L. Detlefs, Antonios Printezis, Steven K. Heller
Life of this patent
Estimating the term…
Abstract
In a generational, copying garbage collector, young generation collection may be made more efficient by dynamically measuring object survival rates as a function of “fine-grained” allocation age, and choosing, on the basis of these survival rates, part of the young generation that will be not be collected, but instead scanned for pointers to objects in the rest of the young generation. The rest of the young generation, including objects referenced by the pointers, is then collected.
Claims12
A computer implemented method for performing garbage collection in a memory heap of a computer system, comprising:
- dividing the memory heap into a young generation and an old generation, wherein the young generation comprises a plurality of regions;
- counting a first number of bytes (NOB) evacuated from a first region during a first garbage collection cycle (GCC);
- counting a second NOB evacuated from a second region during the first GCC, wherein the plurality of regions includes the first region and the second region;
- calculating a first survival rate for the first region based on the first NOB, and a second survival rate for the second region based on the second NOB;
- dividing the plurality of regions, based on a predetermined survival rate boundary, into a prefix group and a suffix group, wherein the prefix group comprises the first region, wherein the suffix group comprises the second region, wherein the first survival rate and the second survival rate are on opposite sides of the predetermined survival rate boundary, and wherein the first survival rate exceeds the second survival rate;
- identifying a plurality of objects in the prefix group comprising pointers to a first plurality of objects in the suffix group;
- evacuating the first plurality of objects in the suffix group from the suffix group to an allocated space outside the suffix group in the memory heap;
- reclaiming memory in the suffix group for reuse by the computer system during a second GCC after evacuating the first plurality of objects in the suffix group, wherein memory in the prefix group is not reclaimed during the second GCC;
- calculating a plurality of garbage collection efficiencies for a plurality of prefix group sizes after reclaiming memory in the suffix group, wherein at least one of the plurality of garbage collection efficiencies is calculated by dividing a dividend comprising a size of an object of the first plurality of objects, by a divisor comprising a time for evacuating the object;
- and
- selecting a prefix group size from the plurality of prefix group sizes for a third GCC, wherein the prefix group size corresponds to a maximum garbage collection efficiency of the plurality of garbage collection efficiencies.
A system for performing garbage collection comprising:
- a processor;
- and
- a memory operatively connected to the processor and storing instructions that perform garbage collection in a memory heap by:
- dividing a memory heap of the memory into a young generation and an old generation, wherein the young generation comprises a plurality of regions;
- counting a first number of bytes (NOB) evacuated from a first region during a first garbage collection cycle (GCC);
- counting a second NOB evacuated from a second region during the first GCC, wherein the plurality of regions includes the first region and the second region;
- calculating a first survival rate for the first region based on the first NOB, and a second survival rate for the second region based on the second NOB;
- dividing the plurality of regions, based on a predetermined survival rate boundary, into a prefix group and a suffix group, wherein the prefix group comprises the first region, wherein the suffix group comprises the second region, wherein the first survival rate and the second survival rate are on opposite sides of the predetermined survival rate boundary, and wherein the first survival rate exceeds the second survival rate;
- identifying a plurality of objects in the prefix group comprising pointers to a first plurality of objects in the suffix group;
- evacuating the first plurality of objects in the suffix group from the suffix group to an allocated space outside the suffix group in the memory heap;
- reclaiming memory in the suffix group for reuse by the computer system during a second GCC after evacuating the first plurality of objects in the suffix group, wherein memory in the prefix group is not reclaimed during the second GCC;
- calculating a plurality of garbage collection efficiencies for a plurality of prefix group sizes after reclaiming memory in the suffix group, wherein at least one of the plurality of garbage collection efficiencies is calculated by dividing a dividend comprising a size of an object of the first plurality of objects, by a divisor comprising a time for evacuating the object;
- and
- selecting a prefix group size from the plurality of prefix group sizes for a third GCC, wherein the prefix group size corresponds to a maximum garbage collection efficiency of the plurality of garbage collection efficiencies.
A computer readable medium storing instructions that perform garbage collection in a memory heap by:
- dividing the memory heap into a young generation and an old generation, wherein the young generation comprises a plurality of regions;
- counting a first number of bytes (NOB) evacuated from a first region during a first garbage collection cycle (GCC);
- counting a second NOB evacuated from a second region during the first GCC, wherein the plurality of regions includes the first region and the second region;
- calculating a first survival rate for the first region based on the first NOB, and a second survival rate for the second region based on the second NOB;
- dividing the plurality of regions, based on a predetermined survival rate boundary, into a prefix group and a suffix group, wherein the prefix group comprises the first region, wherein the suffix group comprises the second region, wherein the first survival rate and the second survival rate are on opposite sides of the predetermined survival rate boundary, and wherein the first survival rate exceeds the second survival rate;
- identifying a plurality of objects in the prefix group comprising pointers to a first plurality of objects in the suffix group;
- evacuating the first plurality of objects in the suffix group from the suffix group to an allocated space outside the suffix group in the memory heap;
- reclaiming memory in the suffix group for reuse by the computer system during a second GCC after evacuating the first plurality of objects in the suffix group, wherein memory in the prefix group is not reclaimed during the second GCC;
- calculating a plurality of garbage collection efficiencies for a plurality of prefix group sizes after reclaiming memory in the suffix group, wherein at least one of the plurality of garbage collection efficiencies is calculated by dividing a dividend comprising a size of an object of the first plurality of objects, by a divisor comprising a time for evacuating the object;
- and
- selecting a prefix group size from the plurality of prefix group sizes for a third GCC, wherein the prefix group size corresponds to a maximum garbage collection efficiency of the plurality of garbage collection efficiencies.
Dependencies are inferred from the claim text.