What is the result of allocating memory using new without storing the returned address anywhere?

Options

  • A. The allocated memory may become inaccessible and cause a memory leak
  • B. The compiler automatically stores the pointer permanently
  • C. The memory is always immediately returned to the operating system
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. The allocated memory may become inaccessible and cause a memory leak

Detailed Explanation

Answer: The allocated memory may become inaccessible and cause a memory leak

If dynamically allocated memory is created but its returned address is not retained, the program may lose the only way to access that memory.

For example:

new int(10);

If the returned address is not stored and no cleanup mechanism exists, the allocated memory cannot later be released through that lost pointer. This can result in a memory leak.