Question:

A program allocates memory dynamically using $malloc()$ and does not free it. After repeated execution, what is the most likely outcome?

Show Hint

In modern languages like Java or Python, a "Garbage Collector" automatically handles this. In C and C++, you must be very disciplined: for every $malloc$, there must be a corresponding $free$.
Updated On: Jul 4, 2026
  • Deadlock
  • Memory Leak
  • Thrashing
  • Starvation
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Concept: Dynamic memory management involves requesting memory from the heap during runtime.
malloc(): A function in C/C++ used to allocate a block of memory.
free(): A function used to release that memory back to the system.

Step 1:
Identifying the problem.
When a programmer uses $malloc()$ to reserve memory but fails to call $free()$ when the memory is no longer needed, that memory remains "occupied" even though the program may no longer have a pointer to access it.

Step 2:
Analyzing the cumulative effect.
If the program runs repeatedly or contains a loop that continues to allocate memory without releasing it, the amount of available system memory steadily decreases. This phenomenon is called a Memory Leak.

Step 3:
Differentiating from other terms.

Deadlock: A situation where two processes are waiting for each other to release resources.
Thrashing: Excessive paging/swapping that slows down the system.
Starvation: A process is perpetually denied necessary resources to process its work. None of these specifically describe the loss of available memory due to unreleased allocations.
Was this answer helpful?
0
0