Answers/Solutions to Exercises in Chapter 4, Exercise 2

E2: Our program requests just one memory allocation of a certain  number of bytes. Checking the memory usage by our program during its execution shows that the dynamic memory increased more than we requested. Is it a sign of memory leaking?

A2: Most likely not. The allocation is really controlled by the operating system, however, for technical reasons, the allocated segments come only in certain sizes. Thus, you are guaranteed a segment of at least the required size. However, the allocated segment should not be way much bigger than what we asked for. Thus, if there is a big discrepancy between the requested memory and the actual usage of memory, it must be a memory leakage.

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