When process exit, will the memory that's left undeleted be returned to OS?

memory-leaks, operating-system

Solution

This isn't so mush a C++ question as an operating system question.

All of the operating systems that I have knowledge of will reclaim conventional memory that had been allocated. That's because the allocation generally comes from a processes private address space which will be reclaimed on exit.

This may not be true for other resources such as shared memory. There are implementations that will not release shared memory segments unless you specifically mark them for deletion before your process exits (and, even then, they don't get deleted until everyone has detached).

Problem

I am wondering if i new some object but forget to delete it, when the process exit, will the leaked memory be returned to the OS?

Original source