3-color bitmap array for garbage collection
The three-color marking technique using bitmaps efficiently identifies and marks objects in heap space by comparing object sizes to an alignment size, addressing inefficiencies in existing garbage collection methods and reducing duplication of effort.
Patent Information
- Application Number
- JP2023512096
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-09-09
- Filing Date
- 2021-09-02
- Publication Date
- 2025-10-15
- Estimated Expiration
- 2041-09-02
AI Technical Summary
Existing garbage collection methods in computer systems face inefficiencies when using bitmaps for three-color marking, as they struggle to efficiently identify and mark objects in unorganized memory spaces like the heap, leading to duplication of effort and resource waste.
Implementing a three-color marking technique that utilizes bitmaps by comparing object sizes to an alignment size, allowing multiple bits to represent objects larger than the alignment size, thereby efficiently marking objects as 'white', 'gray', or 'black' using two bits in the bitmap.
This approach enables efficient identification and marking of objects in heap space, eliminating inefficiencies associated with naive marking techniques and reducing duplication of effort across multiple threads.
Smart Images

Figure 0007754595000001 
Figure 0007754595000002 
Figure 0007754595000003
Abstract
Description
[Technical Field]
[0001] The present disclosure relates to garbage collection in computer systems, and more particularly to marking unreachable resources for garbage collection. [Background technology]
[0002] Some computer systems load resources into memory when a program needs them to complete its function. These resources may be identified by pointers that identify the resources and their location within the program (e.g., within other resources used by the program).
[0003] Some computer systems occasionally perform garbage collection to free memory used by resources that are no longer needed by the computer system (e.g., resources loaded into memory that are no longer being used by the programs that originally required them). For this reason, garbage collection often includes methods for identifying these unnecessary resources. Some methods involve tracking pointers between resources to determine whether any resources in memory are pointed to by programs or other resources that are currently in use. Summary of the Invention
[0004] Some embodiments of the present disclosure may be exemplified as a method that includes identifying a first object at a first memory address. The method may further include calculating a first index location within a bitmap. The first index location may correspond to the first memory address. The method may further include setting a first bit at the first index location. The method may further include detecting a pointer to a child object within the first object. The method may further include identifying a second memory address of the child object using the pointer. The method may further include calculating a second index location within the bitmap. The second index location may correspond to the second memory address. The method may further include setting a second bit at the second index location. The method may further include setting a third bit at a third index location. The third index location may be adjacent to the first index location.
[0005] Some embodiments of the present disclosure can be further exemplified as a system comprising a processor and a memory, the memory being in communication with the processor and including program instructions configured, when executed by the processor, to cause the processor to perform the methods described above.
[0006] Some embodiments of the present disclosure may be further embodied as a computer program product including a program-readable storage medium having computer instructions embodied therein, the program instructions being executable by a computer to cause the computer to perform the above-described method.
[0007] The above summary is not intended to describe each illustrative embodiment or every implementation of the present disclosure. [Brief explanation of the drawings]
[0008] The drawings included in this application are incorporated into and form part of this specification. They illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the disclosure. The drawings are only illustrative of certain embodiments and are not intended to limit the disclosure.
[0009] [Figure 1] 1 illustrates a method for three-color marking using bitmaps according to an embodiment of the present disclosure. [Figure 2A] 1 illustrates an initial abstraction of a bitmap memory system capable of three-color marking in accordance with an embodiment of the present disclosure. [Figure 2B] 1 illustrates a second abstraction of a bitmapped memory system capable of three-color marking in accordance with an embodiment of the present disclosure. [Figure 2C] 1 illustrates a third abstraction of a bitmapped memory system capable of three-color marking in accordance with embodiments of the present disclosure. [Figure 3] 1 illustrates a method for scanning a bitmap for reachable objects according to an embodiment of the present disclosure. [Figure 4] 1 illustrates exemplary major components of a computer system that may be used by embodiments.
[0010] While the invention is susceptible to various modifications and alternative forms, specifics thereof have been shown by way of example in the drawings and will be described in detail. It is to be understood, however, that the intention is not to limit the invention to the particular embodiments described. Rather, the invention covers all modifications, equivalents, and alternatives falling within the spirit and scope of the invention. DETAILED DESCRIPTION OF THE INVENTION
[0011] Aspects of the present disclosure relate to garbage collection in computer systems, and more particularly to marking unreachable resources for garbage collection. While the present disclosure is not necessarily limited to such applications, various aspects of the present disclosure can be appreciated through the discussion of various examples using this context.
[0012] Typical computer systems store resources (also referred to herein as "objects") in memory as they are needed by processes running on those computer systems, either during development or in real-time use. As the program that requested the resource changes, or as the program's purpose changes, resources previously required for the program's operation may no longer be needed. Removing resources that are unnecessarily using system memory can make the system run faster and more smoothly. To this end, many computer systems incorporate garbage collection schemes designed to remove resources from memory that are no longer needed by the computer system. However, in order for garbage collection methods to effectively remove those resources, they must identify the resources that are no longer needed.
[0013] In some computer systems, unnecessary resources can be identified based on whether any other resources in memory reference those unnecessary resources. For example, many computer systems track resources through the use of "pointers." A "pointer," as used herein, refers to a reference to a resource that identifies and provides the location of another resource. A pointer is used by a resource to identify one or more resources that the computer system may need to use during or after using the first resource. A resource in memory is said to be "reachable" when it is identified by a pointer within the resource that can itself be traced back to a root resource (e.g., the object that is first loaded when a program or process is executed). Any object for which this is not true is said to be "unreachable."
[0014] Unreachable objects in memory occupy memory space without providing any benefit to the computer system. Because they are unreachable, no program can use them. Therefore, it is beneficial to identify unreachable resources and remove them from memory. Some computer systems use garbage collection to free memory allocated to unreachable objects. Garbage collection typically involves analyzing the pointers between objects to determine a list of reachable objects and then deleting the unlisted objects.
[0015] For example, some garbage collection methods begin by identifying what is considered to be the root object of a system or process. A root object, as used herein, typically takes the form of the first object loaded by the system within a particular process or program. Root objects are typically stored in a structured section of memory that provides fast and reliable access to them by the computer system. They may reside, for example, in a memory stack or other section of organized memory. By definition, root objects are reachable because of their fast and reliable access and because they are the base objects loaded for a process by the system.
[0016] Root objects often contain pointers to other objects that are required to run a process after the root object is loaded. For example, a resource object for a process may contain linked list items that must be used in order to run that process. In a linked list, each storage object contains a pointer to the location of the next object in the list. Thus, at the root of a list, the root object contains a pointer to the next object in the linked list.
[0017] As used herein, a first object (e.g., a root object) that contains a pointer to a second object is referred to herein as the "parent" or "parent object" of that second object. The second object, in turn, is referred to as the "child" or "child object" of the parent. If the second object also contains a pointer to a third object, the second object is also referred to as the parent of the third object, and the third object is referred to as the child of the second object. Furthermore, the first object is referred to as the "grandparent" or "grandparent object" of the third object, and the third object is referred to as the "grandchild" or "grandchild object" of the first object. Collectively, the children, grandchildren, etc., of an object may be referred to herein as the "descendants" or "descendant objects" of that object.
[0018] In many memory systems, root objects are stored in a highly organized section of memory (e.g., stack memory), while descendant objects are often stored in a less organized, less managed, free-floating section of memory (e.g., heap memory). Unorganized memory is usually larger and more flexible than the organized section of memory, but locating an object within it is more difficult without direction. For this reason, a pointer to an object usually contains information that gives or allows calculation of that object's address within this unorganized section of memory. In other words, by analyzing the pointer to a child object in a parent object, the memory location of that child object can be determined.
[0019] Any descendant object of a root object is then also reachable through the chain of pointers that connects the root object to its descendants. Similarly, any object that is not a descendant of a root object is not reachable. Therefore, many garbage collection systems identify objects to remove from memory by identifying the descendant objects of a root object. For example, a typical garbage collection system begins by identifying a root object and marking it as "reachable" (e.g., in the memory stack). The system then analyzes the root object for pointers to other objects (e.g., the children of the root object). Upon finding a pointer to a child object, a typical garbage collection system can then identify the child object's location in memory and record the object at that memory location as "reachable" in the system's memory management system. A similar process can be performed for the root object's grandchildren, and so on, by analyzing the pointers of the root object's children. Once all pointers of the root object's descendants have been analyzed (and therefore all reachable objects have been identified), any remaining (i.e., unmarked, non-descendant) objects are considered unreachable because there are no pointers from the root object pointing to those unreachable objects.
[0020] In many modern systems, multiple processor threads can work simultaneously to mark objects as "reachable" in the memory management system. However, this can sometimes lead to threads duplicating previous marking work performed by other threads using some marking techniques. For example, if a thread locates a parent object that it has marked as reachable, it may have no way of determining whether the child objects to which the parent object points have themselves been located and marked. For this reason, these marking techniques are sometimes called naive. In naive marking techniques, a thread may spend time analyzing all of the pointers to a parent object to locate the parent's children, even if those children are already marked. This is because, in these marking systems, the only way to determine whether a parent's children are marked is to locate them in memory. If the child objects are not marked, the thread can be used efficiently to mark the parent's children. However, if the child objects have already been marked by another thread, spending time locating the child objects only to find that they have already been marked can waste a significant amount of time, especially if the parent object has many children, which can lead to significant inefficiencies.
[0021] For example, a first thread can scan memory, find a reference to a parent object, locate the memory address of the parent object, and mark it as "reachable." The first thread can then scan the pointers in the parent object, locating the memory addresses of its children and beginning to mark them as "reachable." If a second thread scans memory and finds a reference to the parent object after the first thread has marked them as "reachable," it will not be able to determine whether the parent's children have already been marked using a naive marking technique. This presents the second thread with a choice: locate the parent's children and risk duplicating work already done by another thread, or skip the children and risk leaving them unmarked.
[0022] To address the problems with naive marking techniques, some systems use a three-color marking technique when identifying reachable objects for garbage collection. In three-color marking, objects can be classified into three states: (1) unmarked (often referred to in the industry as "white"), (2) marked with unmarked children (often referred to in the industry as "gray"), and (3) marked with no unmarked children (often referred to in the industry as "black"). In three-color marking, when a thread locates a reference to a "white" object (i.e., an unmarked object), the thread marks the object as "gray" and then determines whether the object points to any unmarked children.
[0023] If a gray object does not point to any unmarked children, it can be marked "black." If a gray object points to any unmarked children, the thread locates them in memory and marks them as well (typically as gray). In some implementations, the parent can be switched to black only when all children have been marked as gray. In other implementations, the parent can be switched to black early in the process (for example, as soon as the thread begins marking its children).
[0024] In the three-color marking technique, when a thread finds a reference to an object marked black, it can conclude that the object and all of its children (if any) are marked, and therefore the thread can move on and continue scanning memory for references to other objects. On the other hand, when a thread finds a gray object, it can conclude that the gray object contains pointers to unmarked children, and it can begin locating and marking those children.
[0025] For example, a first thread can scan memory, find a reference to a parent object, locate the memory address of the parent object, and mark it as "gray." The first thread can then scan the pointers within the parent object, locate the memory addresses of the children, and begin marking the children as gray as well. Once all the children have been marked, the first thread can change the parent to "black."
[0026] In this example, if the second thread locates a reference to a parent before the first thread marks it as black, the second thread will know that the parent has pointers to unmarked children because the parent is "gray." The second thread can then help the first thread locate and mark those children. On the other hand, if the second thread locates a reference to a parent after the first thread has marked it as black, the second thread will know that not only is the parent marked, but that the parent's children have been located and marked as well. In this situation, the second thread will conclude that it should not spend time marking the parent, scanning the parent for pointers, or finding child objects at the pointed-to addresses and verifying that they are marked. Without tricolor marking, the second thread would not be able to make these decisions with confidence.
[0027] However, if a first thread marks one of the parent's children as "gray" and a second thread encounters that child during a memory traversal, the second thread may conclude that this child has been marked by another thread but has a pointer to another child (i.e., the original parent's grandchild) that has not yet been marked. Therefore, the second thread can then analyze the pointers in the original child and begin locating and marking the original parent's grandchild. Importantly, this can occur at the same time that the first thread is still working to locate and identify the original parent's other children. Thus, using three-color marking allows the first and second threads to efficiently work on the same family tree without the risk of duplicating each other's efforts.
[0028] Unfortunately, the three-color marking technique is not easily implemented in all memory systems. For example, some systems use a memory structure called a bitmap to track the occupancy of unmanaged memory space (e.g., heap space). A bitmap typically takes the form of a one-dimensional array of index locations (i.e., a contiguous series of bytes in heap space), each representing a corresponding region of memory. These corresponding regions of memory start at specific locations in memory (sometimes called "memory locations" or "memory addresses"). The specific locations corresponding to these index locations can be determined based on the index location (e.g., multiplying an index location of "4" by 200 to calculate the corresponding memory location of "800," multiplying an index location of 25 by 200 to calculate the corresponding memory location of "5,000"). The size of the region corresponding to each index location in the bitmap can be customized based on the memory system's configuration. For example, in some systems, each index location can point to a two-byte region in unmanaged memory space, while in other systems, each index can correspond to a 20-byte region in memory.
[0029] In a typical bitmap, each index location consists of a single bit, which can be turned on (e.g., set to "1") or off (e.g., set to "0"). Thus, in a bitmap, a single bit can convey information about a much larger region in memory. For example, if each index location corresponds to an 8-byte region in memory, each bit in the bitmap actually conveys information about approximately 64 bytes in memory. Turning these bits on and off can be used to track different information about the corresponding region (e.g., whether the region is occupied, whether the region is being analyzed, whether the region contains frequently used data, or whether the region holds reachable objects). Because this information can represent a relatively large portion of memory in the size of a single bit, bitmaps are often preferred because of their small storage requirements.
[0030] When a typical system using bitmaps performs garbage collection, an object originating at a certain memory location is marked by finding the index position in the bitmap that corresponds to that memory location and toggling the bit at that index position from "0" to "1." However, because each index position can only be either "0" or "1," it is difficult to mark the corresponding object in one of three states (e.g., "white," "gray," or "black"). Thus, when a thread examines a reference to a region of memory marked with "1" in the bitmap, the thread can conclude that a located, reachable object exists at the corresponding location in memory, but it may not be able to conclude whether that object contains any unmarked children. In other words, in some systems that use bitmaps to track memory information, the three-color marking technique suffers from the same disadvantages as the naive marking technique.
[0031] Some embodiments of the present disclosure implement three-color marking in systems that use bitmaps in a manner that avoids the disadvantages of naive marking systems. For example, in some systems, unorganized memory forms heap memory. As previously described, each bit in the bitmap (i.e., each index position) corresponds to an area of memory of the same size. The size of the area of memory to which each bit corresponds is referred to herein as the alignment size. For example, if each bit in the bitmap corresponds to four bytes, the alignment size of the bitmap is four bytes. In these systems, if an object larger than the alignment size (e.g., four bytes) is added to memory, the area in which that object is stored will require more than one bit in the bitmap. In other words, if an eight-byte object is added to an area of heap space in a system with a four-byte alignment size, that area will correspond to two bits in the bitmap.
[0032] Some embodiments of the present disclosure implement three-color marking by comparing the size of an object to an alignment size when marking an object for garbage collection. For example, some embodiments may identify objects that are larger than the alignment size. Because these objects occupy memory space corresponding to at least two index locations in the bitmap, at least two bitmap bits may be used to identify whether the objects are considered "white" or marked as "black" or "gray."
[0033] For example, in some embodiments, if an object occupies a region in heap space corresponding to two index locations in a bitmap, the first index location can be used to indicate whether the object in that region is marked. In other words, the first bit can be off (i.e., set to "0") to indicate that the object is white, or on (i.e., set to "1") to indicate that the object is black or gray. In this example, the second index location can be off to indicate that the object is gray and on to indicate that the object is black. Thus, in these embodiments, a set of bits in the bitmap that read "00" would indicate a white object (e.g., an unmarked object), a set of bits in the bitmap that read "10" would indicate a gray object (e.g., an object that is marked but contains a pointer to an unmarked child), and a set of bits that read "11" would indicate a black object (e.g., an object that is marked and does not contain a pointer or contains a pointer to a marked child). Therefore, by identifying objects larger than the alignment size, embodiments of the present disclosure efficiently identify objects in heap space that allow for three-color marking, even when using bitmaps.
[0034] Although individually identifying objects larger than the alignment size can be a useful method for identifying objects that can be marked with three colors, three-color marking using embodiments of the present disclosure is particularly advantageous when all objects in a heap space are larger than the alignment size. In these cases, three-color marking can be used throughout the heap space, eliminating the inefficiencies of naive marking techniques.
[0035] Accordingly, some embodiments of the present disclosure may attempt to identify whether the minimum object size for a heap space is greater than the alignment size. In a heap space with a "minimum object size," the heap space is divided into equal-sized blocks of contiguous bytes in memory. These equal-sized blocks are sometimes referred to herein as minimum object sizes. For example, a memory system may have a minimum object size of 16 bytes. In this example, memory would be divided into equal-sized 16-byte regions, with no 16-byte region containing more than one object. Thus, if an object that is actually only 7 bytes in size is stored in memory, that object can be allocated one entire 16-byte region. On the other hand, if a 17-byte object is added to memory, it can be allocated two contiguous 16-byte regions. For this reason, the "size of an object" in memory may be understood to refer to the size of the entire region allocated to that object in memory.
[0036] The use of a minimum object size in a memory system can improve the efficiency of mapping memory locations to index locations in a bitmap. However, by identifying a minimum object size that is greater than the alignment size, the use of a minimum object size can further improve the efficiency of three-color marking through embodiments of the present disclosure. For example, the minimum object size for a heap space can be 8 bytes. If a 6-byte object is added to the heap space, it will still be allocated the minimum object size (8 bytes). However, if a 10-byte object is added to the heap space, it will be allocated two regions of the minimum object size (16 bytes).
[0037] By comparing the minimum object size to the alignment size, embodiments of the present disclosure can determine whether at least two bits are available for every object in memory. For example, if the minimum object size is at least twice the alignment size, each object in memory will correspond to at least two bits in the bitmap. In these circumstances, three-color marking using two bitmap bits can be performed for every object in memory.
[0038] 1 illustrates a method 100 for performing three-color marking using a bitmap according to an embodiment of the present disclosure. Method 100 may be performed, for example, by one or more threads of a storage controller or central processing unit of a larger computer system, such as computer system 401. Method 100 may be performed in a system having an organized memory section (e.g., a memory stack), an unorganized memory section (e.g., a heap space), and a bitmap.
[0039] FIG. 1 begins at block 102, in which a thread locates an unmarked object in memory. Block 102 involves identifying the memory location (also referred to as a "memory address") of the unmarked object. In some cases, block 102 may involve the thread initially locating the unmarked root object in a neat section of memory, such as stack space. For example, thread-implemented method 100 may perform block 102 at the very beginning of a garbage collection, when initially scanning stack space for root objects. Alternatively, in some cases, block 102 may involve locating the unmarked object in an unorganized section of memory, such as heap space. For example, thread-implemented method 100 may perform block 102 by following a pointer to an unmarked child object in a parent object.
[0040] In block 104, the thread compares the bitmap and memory to determine whether the size of the unmarked object in memory is sufficiently larger than the alignment size. As previously described, each index position in the bitmap (i.e., each bit in the bitmap) corresponds to an area of the same size in memory. This size of memory to which each bit in the bitmap corresponds is called the alignment size. Therefore, if the unmarked object is smaller in memory than the alignment size, the unmarked object can be referenced by only one bit in the bitmap. For example, each bit in the bitmap can provide information about a 16-byte area of memory. In this example, the alignment size is 16 bytes. If the size of the unmarked object in memory is only 10 bytes, it can be referenced by only one bit in the bitmap. If the unmarked object is referenced by only one bit in the bitmap, it is not convenient to use multiple bitmap bits to represent marking information associated with the object. However, if an unmarked object is 20 bytes in size, it would require more than one bitmap bit to track the total space in memory consumed by that object in the previous example with an alignment size of 16 bytes. If an unmarked object is referenced by two bits in the bitmap, it is possible to use multiple bitmap bits to represent marking information about that object.
[0041] In some embodiments, block 104 not only determines whether an unmarked object is larger than the alignment size, but can also determine how large the unmarked object is. For example, it may be advantageous for an unmarked object to be at least twice the alignment size. In this example, an object's size may simply be "large enough" to be larger than the alignment size if it is twice the alignment size. This may be advantageous, for example, in a memory system in which the minimum size of an object in memory is small compared to the alignment size. For example, a memory system may specify that the minimum object size is 1 byte, but the alignment size is 8 bytes. In this example, a 9-byte object in memory occupies a region that requires two bitmap bits to track. However, because that object consumes only one byte of the 8-byte region tracked by the second bitmap bit, that region may also contain seven other 1-byte objects. Therefore, in such an example, using the second bitmap bit to track the marking of a 9-byte object may be misleading.
[0042] However, if block 104 determines whether the object size is at least twice as large as the alignment size, block 104 can be used to verify that two bitmap bits will be allocated to track the area of memory in which the object is stored, and therefore two bitmap bits will be available to mark the object as white, gray, or black. For example, if the alignment size in a system is 4 bytes, block 104 can be used to determine whether the size of an unmarked object is at least 8 bytes.
[0043] In some embodiments, block 104 can be used to determine whether the object itself is sufficiently larger than the alignment size, as well as whether the space allocated to the object is sufficiently large. For example, some memory systems may require that all objects include a header that describes the object or a footer that provides information about the next object in the process. When performing method 100 on such a memory system, block 104 may take into account the object's header and footer. For example, if the alignment size is 8 bytes and the object is 8 bytes in size but also has an 8-byte header, block 104 may conclude that the object, taking the header into account, is twice the alignment size.
[0044] In some embodiments, the determination of block 104 can be made on a system-wide (or memory-space-wide) basis. In other words, in block 104, a thread may determine whether the minimum object size for a memory space is sufficiently larger than the alignment size, rather than whether a particular object is sufficiently larger than the alignment size. For example, if an object is located in a heap space, the thread executing block 104 may determine whether its minimum object size is sufficiently larger than the alignment size (e.g., twice as large). In these embodiments, block 104 can be performed before block 102, or even before the garbage collection process or marking for the garbage collection process begins. Rather, block 104 can be performed as a preliminary measure and stored as system configuration in these embodiments.
[0045] If the thread determines at block 104 that the object size (e.g., the memory area allocated to the object, including the header, footer, etc.) is not sufficiently larger than the alignment size, the thread concludes that multiple bitmap bits should not be used to perform the three-color marking of the object, and method 100 ends at block 106. However, if the thread determines that the object size is sufficiently larger than the alignment size, the thread proceeds to block 108, where the thread identifies the corresponding index location(s) of the unmarked object.
[0046] In block 108, the thread may perform a calculation that can convert the memory address of an unmarked object (e.g., as may have been identified in block 102) into an index location in the bitmap. For example, the thread may divide the memory address by a predetermined integer (e.g., 100) and then subtract another predetermined integer (e.g., 200) from the resulting quotient. As a result of this calculation, an index location may be identified that corresponds to the memory address of the memory region in which the unmarked object is stored.
[0047] In some embodiments, block 108 may include identifying multiple index locations. The number of index locations calculated may depend on the size of the unmarked objects relative to the alignment size. For example, if the size of the unmarked objects is four times the alignment size, the entire area in which the unmarked objects are stored corresponds to four bits in the bitmap. In this example, the thread executing block 108 may detect that multiple bitmap bits correspond to the unmarked objects and identify all of those bitmap bits. In some embodiments, the thread may identify only two of the bitmap bits, even if more than two bits correspond to the unmarked objects. For example, if the area occupied by the unmarked objects corresponds to 10 bitmap bits, the thread may identify only the first two index locations (e.g., the two index locations corresponding to the lowest memory address occupied by the object) or the last two index locations (e.g., the two index locations corresponding to the highest memory address occupied by the object).
[0048] Once a thread identifies index locations that correspond to the memory locations of unmarked objects, the thread proceeds to block 110 and sets a bit at "first" in those index locations. In other words, the thread toggles the bit at the first index location from "0" to "1." By setting the first bit to 1, the thread records the fact that the unmarked object located in block 102 is now marked and is considered "gray" or "black." This marking informs the garbage collecting system that there is an object reachable at the memory address corresponding to that first index location, and therefore, that object should not be deleted.
[0049] Determining what the “first” index location is in block 110 may depend on other configurations of the system. For example, in some embodiments, the first index location may depend on the direction in which the thread is programmed to traverse the bitmap for unmarked objects. While not essential, it may be advantageous for the “first” index location to be the first index location identified in block 108 that the thread encounters as it traverses the bitmap. If the thread is programmed to traverse the bitmap in an ascending direction (i.e., starting at an index location corresponding to a lower memory address and progressing toward an index location corresponding to a higher memory address), the “first” index location may be the index location corresponding to the lowest memory address occupied by an unmarked object. However, if the thread is programmed to traverse the bitmap in a descending direction, the “first” index location may be the index location corresponding to the highest memory address occupied by an unmarked object. In some embodiments, even if there are more than two corresponding index locations identified in block 108, the "first" index location can always be one of the two index locations corresponding to the two lowest or two highest memory addresses occupied by unmarked objects. In these embodiments, the "first" index location of these two index locations can still be determined by the traversal direction of the thread. In other words, if a thread is programmed to traverse the bitmap in a downward direction and four index locations are identified in block 108, block 110 can set the first bit to the second lowest index location (i.e., the index location corresponding to the second lowest memory address occupied by an unmarked object).This is because the next lowest of the two lowest index locations will be analyzed first by a thread that traverses the bitmap downwards.
[0050] If a bit is set at the first identified index location in block 110, the "unmarked" object can be considered to be marked "gray." This means that the object itself is located and marked, but may have unmarked children. Thus, after marking the object as gray in block 110, the thread proceeds to determine whether the object has at least one unmarked child in block 112. For example, the thread can analyze the contents of the object in memory to determine whether the object contains any pointers to other objects (i.e., children). In most cases, if a previously unmarked object has children, those children will be unmarked. Thus, in most cases, the thread can safely assume in block 112 that if a gray object has pointers to its children, those children are unmarked.
[0051] If the thread determines in block 112 that the gray object has no unmarked children, the thread may set a bit in a second identified index location in block 114. This second index location should be among the index locations identified in block 108 as corresponding to the memory region in which the object is stored. When the bit in the second location is set, the "gray" object can be considered "black," meaning that the object has been located and marked as "reachable" and that the object has no children that have not been located and marked as "reachable."
[0052] The "second index location" in block 114 may be adjacent to the first index location. This may be advantageous because only two adjacent bits in the bitmap are required for three-color marking. For example, if a thread were scanning the bitmap for an object, the thread might find that a bit is set at the first index location. The thread could conclude that a reachable object is stored in memory at the memory address corresponding to that first index location. By scanning the next adjacent bit, the thread could also conclude whether the object has any unmarked children.
[0053] Whether the selected second index location is upstream in the bitmap (i.e., at a higher memory address) or downstream in the bitmap can be determined based on the traversal position of the thread in the system, as discussed in connection with block 110. For example, if the thread is programmed to traverse the bitmap in an ascending direction (i.e., from an index location corresponding to a lower memory address to an index location corresponding to a higher memory address), it may be advantageous to select a higher index location.
[0054] If the thread determines in block 112 that the object has at least one unmarked child, the thread follows the pointer to the child in the gray object to locate the child in memory in block 116. Locating the child in memory may vary based on the system specifications and the contents of the pointer, but typically the child is located using information in the pointer to determine the child's memory address. Once the child's memory address is located, the thread can also identify a corresponding index location in a bitmap for that memory address. Once the corresponding index location for the child's memory address is identified, the thread can set a bit in that index location to indicate that the child has been located and marked. This indicates to other threads that the memory location corresponding to that index location contains a reachable object.
[0055] After locating and marking the child in block 116, the thread proceeds to block 114 and sets a bit in the second index location for the parent object (i.e., the object located in block 102). The thread then determines in block 118 whether the parent object contains a pointer to any other children. If the parent has more children, the thread proceeds to locating and marking the next child in block 120. This locating and marking may be similar to the locating and marking of block 116. After locating and marking the next child in block 120, the thread returns to block 118 and again determines whether more children exist. If the thread determines in block 118 that the parent object (i.e., the object located in block 102) does not have any more pointers to child objects, the thread exits method 100 in block 116.
[0056] 1 illustrates one possible order of operations for method 100, in some other embodiments the exact timing and order of operations may differ from that described above. For example, in some embodiments, the exact timing of setting the second bit for a parent in block 114 may depend on the system configuration, the number of children pointed to by the parent, and the proximity of the child and parent objects.
[0057] For example, in some embodiments, the bit at the second index location may not be set in block 114 until a threshold percentage of the parent object's children have been marked "gray" (e.g., through blocks 116, 118, and 120). This may be advantageous when a parent has a large number of children, because setting the second bit at block 114 signals to other threads traversing the bitmap that all of the parent's children have been marked. While this may be useful for avoiding duplication of effort, it may prevent other threads from assisting in marking the parent's children if the parent has a very large number of children. In such cases, the possibility of some duplication of effort justifies the performance benefit of multiple threads working to locate and mark the large number of children. Thus, for parent objects with a number of children exceeding a threshold (e.g., 50), a thread may not set the bit at the second index location at block 114 until a threshold number of the parent's children have been marked. For example, if a parent (e.g., the object marked in block 102) has 100 children, the threshold can be set to 50% (i.e., 49 repetitions of blocks 118 and 120 plus 1 repetition of block 116).
[0058] On the other hand, in some cases, the thread may attempt to set the second bit in block 114 as long as it is advantageous to do so in the child marking process. When it is “advantageous” to set the second bit in block 114 may depend on the proximity of the parent object (i.e., the object located in block 102) to the child object. For example, if the child object located and marked in block 116 is close to the parent object in the bitmap, the parent's second bit and the child's first bit may be marked simultaneously (e.g., in the same “compare and swap” instruction). However, if the child object located and marked in block 116 is not close to the parent object, the thread may delay setting the second bit in block 114 until the child is close to the parent, which is located during the iteration of blocks 118 and 120. For example, a thread can proceed directly from block 116 to block 118 and block 120. If the child located during the first iteration of blocks 118 and 120 is located near the parent object, the thread can mark the child and simultaneously set the second bit in block 114. If not, the thread again delays block 114 and performs another iteration of blocks 118 and 120. While this implementation can avoid extra instructions for setting a bit in the bitmap, delaying the setting of the bit at the second index location in block 114 can increase the chance that another thread will find the parent object in a bitmap scan, conclude that it is gray, and duplicate effort by scanning the parent's children (e.g., by executing blocks 116, 118, and 120).Thus, a thread programmed to delay block 114 in this manner may also be programmed to perform block 114 after a threshold number of iterations of blocks 118 and 120 have been performed (e.g., 20 iterations).
[0059] In some cases, it may be advantageous for a thread to set the second bit in the second index location in block 114 as soon as possible. Setting the bit in the second index location effectively marks the parent object as "black," thereby informing the thread that all of the parent object's children have been marked. This means that the thread can then skip analyzing the parent for pointers and move on to scanning the bitmap for other objects. This can minimize the risk that another thread will locate the parent object in a bitmap scan and begin attempting to locate and mark children that have already been marked and located by another thread.
[0060] For understanding, Figures 2A-2C show an abstract view of a memory system 200 in which three-color marking can be used in a bitmap, according to an embodiment of the present disclosure. Figure 2A shows an initial view of memory system 200 before any objects have been marked as reachable.
[0061] Memory system 200 includes stack space 202, an organized and ordered portion of memory that is heavily managed by the system's computer processing unit (CPU). Memory system 200 also includes heap space 204, a larger, less organized section of memory that can store most resource objects for the system. The contents of heap space 204 can be mapped by bitmap 206, a one-dimensional matrix of index locations, each containing a single bit. Index locations 208 and 210 represent bits in bitmap 206 that correspond to the maximum and minimum memory addresses of heap space 204, respectively. Bitmap 206 is shown to contain only 19 index locations for ease of understanding, but in reality, bitmaps can contain a much larger number of index locations depending on the size of the heap space they track.
[0062] Stack space 202 includes root object 212. When a thread begins performing tricolor marking in memory system 200, it can analyze root object 212 to discover a pointer to a child object (object 214). Analyzing that pointer provides the thread with the object's memory location (i.e., memory address) in heap space 204. This analysis is represented by dashed line 216. Using the memory address of child 214, the thread can identify index locations in the bitmap (index locations 216-222) that correspond to the memory address of the region of heap space 204 where object 214 is stored. This identification is represented by dashed line 224, and the region of the bitmap encompassing these index locations is shown by dashed box 226.
[0063] FIG. 2B shows a next diagram of memory system 200. In FIG. 2B, a thread sets a bit at index location 216 to indicate that there is an object (object 214) reachable at the memory address corresponding to index location 216. Because a thread in memory system 200 can be programmed to traverse the bitmap for objects in an ascending order (i.e., from index location 208 to index location 210), the thread can select index location 216 rather than any other bit in bitmap region 226 because index location 216 is the first index location within region 226 that the thread will encounter while traversing bitmap 206. Thus, a bit set at index location 216 can indicate to the thread that the object corresponding to that index location (object 214) is marked "gray," while a bit set at the next index location for that object (e.g., index location 218) can indicate that the object is marked "black."
[0064] Setting the bit at index location 216 allows a thread to analyze the object and discover that it has three pointers 228, 230, and 232 to child objects 234, 236, and 238. By analyzing one of those pointers, the thread can determine the location of one of the child objects in memory. As an example, dashed line 240 indicates the analysis in which the thread analyzes pointer 232 to determine the memory address of child object 238.
[0065] By determining the memory address of child object 238, the thread can then identify the corresponding index location in bitmap 206 that corresponds to the region of memory occupied by child object 238. This identification is indicated by dashed line 242, which shows region 244 of bitmap 206 whose index location corresponds to the memory region in which child object 238 is located. Index location 246 is the "lowest" of these index locations and will be traversed by threads traversing the bitmap in an ascending direction.
[0066] 2C shows the next diagram of memory system 200. In FIG. 2C, the thread that identified the index location corresponding to child object 238 sets a bit at index location 246. This, in effect, marks child object 238 as "gray" and informs other threads traversing the bitmap that a reachable object occupies the memory region associated with index location 246. As depicted in FIG. 2C, the thread that identified the index location corresponding to child object 238 also sets a bit at index location 218.
[0067] The adjacent bits 216 and 218, both set, inform other threads traversing the bitmap that a reachable object occupies the memory region associated with index locations 216 and 218 and that the reachable object's children do not need to be located and marked. In other words, setting the bit at index location 218 effectively changes the marking of object 214 from "gray" to "black." In some embodiments, the bit at index location 218 may be set when the first child of object 214 is marked. This may prevent any other thread from assisting in locating and marking the remaining children of object 214 (e.g., child objects 234 and 236), but it may also help prevent duplication of effort (e.g., another thread attempting to locate and mark child object 238 after it has already been marked). In some embodiments, the bit at index location 218 can be set when the last child of object 214 is marked. This increases the chance that another thread can help locate and mark the remaining children of object 214, but also increases the chance of duplication of effort. In some embodiments, the bit at index location 218 can be set after a threshold number of children of object 214 have been marked, or at the same time as any child objects that may be marked in the same compare-and-swap instruction as index location 218.
[0068] Once the thread has located and marked all child objects pointed to by object 214, it can continue to scan bitmap 206 for gray objects. Once the thread has located a gray object, it can locate that object in heap space and follow its pointers to begin locating and marking its children.
[0069] As shown in FIG. 2A, a thread scanning bitmap 206 in an ascending order (e.g., starting at index location 208 and scanning toward 210) may first encounter a bit set at index location 216. If threads in a memory system are programmed to set a bit at the "lowest" index location when marking an object as gray, the thread can assume, by detecting the bit set at index location 216, that a reachable object (i.e., object 214) is located in the heap space region corresponding to the index location and that the reachable object is marked as "gray." However, the thread does not immediately know whether the children of object 214 have been located and marked. By scanning the next index location, index 218, the thread can infer, however, that the object has been marked as "black" (especially in systems where the minimum object size is greater than the alignment size). This means that all children of object 214 are marked or are in the process of being marked. Therefore, we can conclude that the thread does not need to locate object 214 in the heap space or follow the pointers of object 214 to locate and mark its children.
[0070] Upon learning that object 214 has been marked "black," the thread can continue scanning bitmap 206 until it finds a bit set at that index location. This, like the bit set at index location 216, again informs the thread that the reachable object at the corresponding heap space location (i.e., child object 238) has been marked "gray." However, by scanning the next index location (index location 248) and finding a bit set there, the thread can conclude that child object 238 has not yet been marked "black." This means that child object 238 may still have several reachable children that need to be located and marked, and therefore the thread can begin locating child object 238 in the heap space and analyzing it for pointers.
[0071] As previously described, a first thread may have set a bit at index location 218 while locating and marking the children of object 214. Thus, a second thread may detect that object 214 has been marked "black" and, based on that detection, continue scanning and discover that its child object 238 has been marked "gray" but not yet marked "black." Thus, the second thread may begin locating and marking the children of child object 238 while the first thread is still locating and marking child objects 234 and 236. In this manner, three-color marking may be used to obtain the efficiency benefits of multiple threads within memory system 200 while reducing the likelihood of duplicated effort.
[0072] 3 illustrates a method 300 for scanning a bitmap for reachable objects. Method 300 further illustrates how a thread identifying reachable objects for garbage collection can use the three-color marking system of the present disclosure. For example, method 300 can be performed by the "second thread" discussed in connection with FIG. 2C.
[0073] Method 300 begins at block 302, where a thread scans an index location. In some cases, the index location may be the first index location or the next index location in the bitmap. In some embodiments, the thread may scan the bitmap in an ascending direction, while in other embodiments, the thread may scan the bitmap in a descending direction. In block 304, the thread determines whether a bit is set (i.e., set to “1”) at the index location scanned in block 302 (referred to herein as the first index location). If the thread determines that the bit is not set, the thread may conclude that the memory at the location corresponding to the first index location does not contain an object marked as “reachable.” The thread then proceeds to scan the next index location in the bitmap (referred to herein as the “second” index location) in block 306. The thread then returns to block 304 to determine whether a bit is set at the second index location.
[0074] If, at block 304, the thread determines that a bit is set at an index location (e.g., at the second index location), the thread can conclude that a reachable object is located at the memory address corresponding to that index location. This informs the thread that the object is marked as "gray," but the thread cannot determine whether the object is marked as "black" based solely on that index location (e.g., the second index location). Therefore, the thread then proceeds to scan the next index location in the bitmap (referred to herein as the "third" index location) at block 308.
[0075] The thread then determines whether the bit is set at the next index location (e.g., the third index location) in block 310. If the thread determines that the bit is set, the thread can conclude that the object has been marked as "black" because the bits were set at the two preceding index locations (e.g., the second and third index locations). This informs the thread that the children of the marked object have been located and marked, or that a sufficient number of children have been marked and no further assistance is needed with respect to the children. Thus, the thread can skip the black object in block 312 and proceed to scan the next index location in block 306.
[0076] On the other hand, if, in block 310, the thread determines that the bit is not set, it can conclude that the object has been marked "gray" because only one of the two preceding index locations (e.g., the second and third index locations) exhibited a set bit. This informs the thread that either none of the marked object's children have been marked, or that the number of marked children is sufficiently small that assistance in locating and marking the remaining children would be beneficial. Thus, the thread would next proceed to load the "gray" object from memory in block 314 and analyze the pointers within the object to locate and mark its children in block 316. In this manner, multiple threads can be used to locate and mark reachable objects in memory without the undesirable risk of duplicating effort.
[0077] FIG. 4 illustrates representative major components of an exemplary computer system 401 that can be used in accordance with embodiments of the present disclosure. The individual components illustrated are shown for purposes of example only and are not necessarily variations thereof. The computer system 410 can include a processor 410, memory 420, an input / output interface (also referred to herein as I / O or I / O interface) 430, and a main bus 440. The main bus 440 can provide a communication path for other components of the computer system 401. In some embodiments, the main bus 440 can be connected to other components, such as a special-purpose digital signal processor (not shown).
[0078] The processor 410 of the computer system 401 may include one or more CPUs 412. The processor 410 may further include one or more memory buffers or caches that provide temporary storage of instructions and data for the CPU 412. The CPU 412 may execute instructions on input provided from the cache or memory 420 and output results to the cache or memory 420. The CPU 412 may include one or more circuits configured to perform one or more methods consistent with embodiments of the present disclosure. In some embodiments, the computer system 401 may include multiple processors 410, as is typical of larger systems. However, in other embodiments, the computer system 410 may be a single processor having only one CPU 412.
[0079] The memory 420 of the computer system 401 may include a memory controller 422 and one or more memory modules (not shown) for temporarily or permanently storing data. In some embodiments, the memory 420 may include a random-access semiconductor memory, storage device, or storage medium (volatile or non-volatile) for storing data and programs. The memory controller 422 may communicate with the processor 410 and facilitate the storage and retrieval of information in the memory modules. The memory controller 422 may communicate with the I / O interface 430 and facilitate the storage and retrieval of inputs and outputs in the memory modules. In some embodiments, the memory modules may be dual in-line memory modules.
[0080] I / O interface 430 may include an I / O bus 450, a terminal interface 452, a storage interface 454, an I / O device interface 456, and a network interface 458. I / O interface 430 may connect main bus 440 to I / O bus 450. I / O interface 430 may direct instructions and data from processor 410 and memory 420 to various interfaces of I / O bus 450. I / O interface 430 may also direct instructions and data from the various interfaces of I / O bus 450 to processor 410 and memory 420. The various interfaces may include terminal interface 452, storage interface 454, I / O device interface 456, and network interface 458. In some embodiments, the various interfaces may include a subset of the above interfaces (e.g., an embedded computer system for industrial applications may not include terminal interface 452 and storage interface 454).
[0081] Through computer system 401, including but not limited to memory 420, processor 410, and I / O interface 430, the logical modules can communicate failures and changes to one or more components to a hypervisor or operating system (not shown). The hypervisor or operating system can allocate various available resources within computer system 401 and track the location of data in memory 420 and processes assigned to various CPUs 412. In embodiments that combine or reorganize elements, aspects of the logical modules' capabilities can be combined or redistributed. These variations will be apparent to those skilled in the art.
[0082] The present invention may be embodied as a system, method, or computer program product, or combination thereof, at any possible level of technical detail. The computer program product may include computer-readable storage medium(s) having computer-readable program instructions for causing a processor to perform aspects of the present invention.
[0083] A computer-readable storage medium may be any tangible device capable of holding and storing instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. A non-exhaustive list of more specific examples of computer-readable storage media includes the following: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disks (DVDs), memory sticks, floppy disks, punch cards, or mechanically encoded devices such as ridge structures in grooves having instructions recorded thereon, and any suitable combination of the above. As used herein, computer-readable storage media is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., light pulses through fiber optic cable), or electrical signals sent through wires.
[0084] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device or to an external computer or storage device over a network, such as the Internet, a local area network, a wide area network, or a wireless network, or a combination thereof. The network can include copper cables, optical fibers, wireless networks, routers, firewalls, switches, gateway computers, or edge servers, or a combination thereof. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and transfers the computer-readable program instructions for storage in a computer-readable storage medium within the respective computing / processing device.
[0085] The computer-readable program instructions for carrying out the operations of the present invention may be source or object code written in any combination of one or more programming languages, including assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, configuration data for integrated circuits, or object-oriented programming languages such as Smalltalk, C++, and conventional procedural programming languages such as the "C" programming language or similar programming languages. The computer-readable program instructions may run entirely on the user's computer, partially on the user's computer as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) can execute computer readable program instructions to individualize the electronic circuitry by utilizing state information in the computer readable program instructions to implement aspects of the present invention.
[0086] Aspects of the present invention will be described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0087] These computer-readable program instructions can be provided to a processor of a computer or other programmable data processing apparatus to produce a machine, whereby the instructions, executed by the processor of the computer or other programmable data processing apparatus, create means for performing the functions / acts specified in one or more blocks of the flowcharts or block diagrams, or both. These computer program instructions, which can direct a computer, programmable data processing apparatus, or other device, or combination thereof, to function in a particular manner, can also be stored in a computer-readable medium, whereby the instructions stored in the computer-readable medium include an article of manufacture containing instructions implementing aspects of the functions / acts specified in one or more blocks of the flowcharts or block diagrams, or both.
[0088] The computer-readable program instructions may be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, whereby the instructions executing on the computer or other programmable apparatus provide a process for performing the functions / operations specified in one or more blocks of the flowchart or block diagram, or both.
[0089] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts may represent a module, segment, or portion of code, including one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions shown in the blocks may occur in a different order than that shown in the figures. For example, two blocks shown in succession may in fact be executed substantially simultaneously, or the blocks may sometimes be executed in the reverse order, depending on the functionality involved. It should also be noted that each block of the block diagrams and / or flowchart diagrams, and combinations of blocks in the block diagrams and / or flowchart diagrams, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or a combination of dedicated hardware and computer instructions.
[0090] The descriptions of various embodiments of the present disclosure have been presented for illustrative purposes, but they are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terms used herein have been selected to best explain the principles of the embodiments, practical applications, or technical improvements over the art found in the market, or to enable those skilled in the art to understand the embodiments disclosed herein.
Claims
1. 1. A method of marking objects for garbage collection in a computer system by an information processing device of said computer system, comprising: Identifying a first object at a first memory address; determining whether an object size of the first object is greater than an alignment size for a bitmap; If it is determined that the object size of the first object is larger than the alignment size for the bitmap, calculating a first index position within the bitmap corresponding to the first memory address; setting a first bit at the first index location; Finding a pointer to a child object within the first object; using the pointer to identify a second memory address of the child object; calculating a second index position within the bitmap corresponding to the second memory address; setting a second bit at the second index position; setting a third bit at a third index position adjacent to the first index position; A method comprising:
2. 2. The method of claim 1, wherein setting the first bit means that the first object is marked as "gray" and setting the third bit means that the first object is marked as "black."
3. The method of claim 1 , further determining to set the third bit when the second bit is set.
4. 4. The method of claim 3, wherein the third bit is set by the same compare-and-swap instruction that set the second bit.
5. 4. The method of claim 3, wherein determining to set the third bit when the second bit is set is based on detecting that the number of children pointed to by the first object is less than a threshold.
6. The method of claim 1 , wherein the third bit is set upon detecting that all children of the first object have been located and marked as "gray."
7. scanning the first index location; detecting that the first bit is set; concluding that a first reachable object at the first memory address is marked "gray" based on detecting that the first bit is set; scanning the third index location; detecting that the third bit is set; and concluding that the first reachable object at the first memory address is marked "black" based on detecting that the third bit is set; and The method of claim 1 further comprising:
8. a processor; a memory in communication with the processor containing program instructions configured, when executed by the processor, to cause the processor to perform a method; Including, The method comprises: Identifying a first object at a first memory address; determining whether an object size of the first object is greater than an alignment size for a bitmap; If it is determined that the object size of the first object is larger than the alignment size for the bitmap, calculating a first index position within the bitmap corresponding to the first memory address; setting a first bit at the first index location; Finding a pointer to a child object within the first object; using the pointer to identify a second memory address of the child object; calculating a second index position within the bitmap corresponding to the second memory address; setting a second bit at the second index position; setting a third bit at a third index location adjacent to the first index location; Including, system.
9. The system of claim 8 , wherein the method further comprises determining to set the third bit when the second bit is set.
10. 10. The system of claim 9, wherein determining to set the third bit when the second bit is set is based on detecting that the number of children pointed to by the first object is less than a threshold.
11. The method comprises: scanning the first index location; detecting that the first bit is set; concluding that a first reachable object at the first memory address is marked "gray" based on detecting that the first bit is set; scanning the third index location; detecting that the third bit is set; and concluding that the first reachable object at the first memory address is marked "black" based on detecting that the third bit is set; and The system of claim 8 further comprising:
12. A computer program comprising computer readable program instructions for causing a computer to carry out the method of any one of claims 1 to 7.
13. 13. A computer readable storage medium having stored thereon the computer program of claim 12.
Citation Information
Patent Citations
Memory reclamation method
JP2002540503A
Device and method of garbage collection
JP2003050740A
System and method for garbage collection in heterogeneous multiprocessor system
JP2007299403A
Method and system for improving the concurrency and parallelism of mark-sweep-compact garbage collection
US20050198088A1