Linkers, Loaders & Executables

After repeated malloc and free, a large block may become impossible to allocate even though total free memory is sufficient. What is this phenomenon called?

  1. AA memory leak
  2. BFragmentation
  3. CA stack overflow
Show answer and explanation

Answer: B. Fragmentation

Repeatedly allocating and freeing blocks of different sizes scatters small free gaps between blocks in use. Even if total free space is large, a big allocation fails without a large contiguous gap. This is called fragmentation. Allocators reduce it by managing blocks by size class and merging adjacent free blocks. It needs special care in embedded devices that run for a long time.

  • A. A memory leak is losing memory by forgetting to free it.
  • B. Correct. Free space is split into small pieces.
  • C. A stack overflow is exceeding the stack limit.
Practice this topic Back to topic

More Linkers, Loaders & Executables questions

  1. When building a shared library, what is the advantage of exporting only the public functions and giving internal functions "hidden" symbol visibility?
  2. How does C++ run the constructors of global objects before main?
  3. Which statement is correct about the object file (.o) a compiler produces from one source file?
  4. What is the main role of a linker?
  5. Which describes the symbol resolution a linker performs?