Quiz submission record for quiz2-1-1 at Mon Jun 28 02:23:26 2004: Your Answer for Question 1: a. False. For example, if there are not any big-enough free blocks, another large chunk of memory may be obtained from the OS and linked into the free list so that malloc can take some of the memory. b. True. For example, if no big-enough free chunk exists and trying to get more memory from the OS using morecore() was not possible, then the number of free blocks does not change. Or if a too-big chunk was found and split, and one part taken by malloc, there would still be the other part of the chunk left - in this way, the number of free blocks remains the same. c. True. For example, if there is no free list yet, then one is created and a big block of memory is grabbed from the OS and split so malloc can have some. Thus, the number of free blocks increases. Your Answer for Question 2: a. False. In some cases, if free inserts the block being freed between two existing free blocks, then it will combine them all into one big block. Then, a fewer number of freed blocks will exist. b. True. For example, if an adjacent block is free, the call to free would merge this with the block being freed, and the number of free blocks would remain the same. c. True. If the block being freed is inserted between two free blocks, all three would be combined to reduce the number of free blocks by 1. However, there cannot be more since more free blocks adjacent to the already free blocks would already have been combined. d. False. Because there cannot be more already free blocks adjacent to other already free blocks (they would already have been combined), a call to free may not reduce the number of free blocks by more than 1. Your Answer for Question 3: The Java equivalent to malloc in C is new. delete is the Java equivalent to C's free. Because one can cast pointers in C to and from other pointer types, and this would not change the contents of the allocated storage, one wouldn't be able to tell if the memory was not longer needed. Your Answer for Question 4: Reference count method: Yes. Since the top left node does not have any pointers going to it (not being pointed to by a root (?)) it will be deleted. In turn, all of the other nodes will be deleted since the three pointers coming from that node will be gone, and there will be no way to reach the other nodes. Mark and sweep method: Yes. Since the objects cannot be reached from a root, they will not be marked, and when the sweep happens, they will all be reclaimed. Your Answer for Question 5: I was confused by the garbage collection graphs. What makes something a root, and another just a normal object? How come the objects that pointed to each other pointed to null? The explanation about the buddy system was also a bit confusing. Does C use the buddy system? Your unique submission ID is quiz2-1-1-cs61c-ep-1088414606-1217.