Answers/Solutions to Exercises in Chapter 3, Exercise 9

E9: We are using a garbage-collector with our C program. We know that whenever a memory segment previously allocated is not referenced in our program any longer, the garbage-collector may deallocate it. In order to prevent an unwanted deallocation, we keep addresses of the segments we do not want to lose in a special file. Will this help us?

A9: Of course not, since the garbage-collector does not "know" about this reference. It only knows about the references it can infer from the source code of the program during the compilation process. In simple terms, there must be a variable in the program that references the segment we want to protect from the garbage-collector.

Back to Answers/Solutions Index                          Back to Answers/Solutions for Chapter 3 Index