0

I am trying to allocate memory using new keyword in c++.

I was just wondering If memory is still allocated even after the program ends. meaning if there is still a memory leak.

Chris
  • 26,361
  • 5
  • 21
  • 42
Aarsh
  • 370
  • 1
  • 3
  • 13
  • 5
    No, all memory allocated by the program will be released when the program ends. – john Aug 20 '22 at 05:50
  • 2
    It actually depends on the host system. Modern operating systems (windows, unix) running on hardware with a MMU (memory management unit) will - by design - recover memory from processes as they terminate. On such platforms, memory leaks are mostly a concern for long-running processes. Other, more basic, systems (e.g. software running "on the metal") will not recover allocated memory. – Peter Aug 20 '22 at 06:28
  • Makes me wonder if that is actually UB. – Goswin von Brederlow Aug 20 '22 at 08:46

0 Answers0