| 1. |
If An Object Is Created Without Any References To It, How Can That Object Be Deleted? |
|
Answer» If an object is created without any references to it, it can neither be accessed nor deleted via a program. The only way is for the DATABASE system to locate and delete such objects by itself. This is called garbage collection. One way to do garbage collection is by the method of MARK and sweep. First, the objects referred to directly by programs are MARKED. Then references from these objects to other objects are followed, and those referred objects are marked. This procedure is followed repeatedly until no more unmarked objects can be reached by following reference chains from the marked objects. At this point, all these remaining unmarked objects are deleted. This method is correct; we can prove that if no new objects are marked after a round of mark and sweep, the remaining unmarked objects are INDEED unreferenced. If an object is created without any references to it, it can neither be accessed nor deleted via a program. The only way is for the database system to locate and delete such objects by itself. This is called garbage collection. One way to do garbage collection is by the method of mark and sweep. First, the objects referred to directly by programs are marked. Then references from these objects to other objects are followed, and those referred objects are marked. This procedure is followed repeatedly until no more unmarked objects can be reached by following reference chains from the marked objects. At this point, all these remaining unmarked objects are deleted. This method is correct; we can prove that if no new objects are marked after a round of mark and sweep, the remaining unmarked objects are indeed unreferenced. |
|