Does the memory remains assigned if I didn't free the allocated memory using malloc
even after exiting the program?
It's running in Ubuntu Linux 14.
Does the memory remains assigned if I didn't free the allocated memory using malloc
even after exiting the program?
It's running in Ubuntu Linux 14.
In theory its platform specific but the chances are that the system will reclaim all memory and other resources allocated by a process when it exits.
So, no, memory probably won't remain assigned after your program exits. Note however if your program is long running and leaks memory, its memory requirements might become very high. You should make reasonable efforts to avoid memory leaks and should not just rely on the system (eventually) cleaning things up for you.
Edit: Your updated question states you're running on Linux. Linux will clean up resources allocated by your process when your program exits.
This is not related to C++ or any other language. This is a question about operating systems. The process you are running is using resources (memory in this case). Upon exit, the OS takes it back so it can give it to other processes.
This is physical memory we are talking about. Virtual memory belongs to the process, so there is nothing to reclaim at all. It simply does not exist anymore.
It depends on the system, but most likely the memory will be available after the program stops.
On linux, malloc would return a virtual memory adress but would not use the physical memory until you actually write something on it.