Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will memory release if I stop debugging directly?

I want to know, suppose I am debugging a code and at any point I allocated some memory and break point hits for example:

1: Statement to allocate 1 MB memory in **C**.
2: Any other statement where **BREAKPOINT HIT**.  

Now my question is:

  1. If I will kill my IDE (like visual studio) directly using task manager then allocated memory and resources will free or not.
  2. If I will stop debugging then allocated memory and resources will free or not.

If yes then How can I confirm it whether memory and resources have freed.

like image 655
Bharat Sharma Avatar asked Oct 01 '22 23:10

Bharat Sharma


1 Answers

On modern operating systems, all the memory for your program is returned to the system when the program is terminated, which will happen in either of those cases. This might not happen on some embedded systems, but you wouldn't be running an IDE on those.

For other resources than memory, e.g., open files, devices, etc., the OS will generally reclaim all resources (unless they're still in use by other processes), but for some systems and some resources, under some conditions, resources can be lost or locked (which should be considered a bug in the OS or the device driver).

As far as determining that the system actually freed the memory, it can be quite difficult because the system allocates memory to buffers and swap areas and doesn't necessarily have a count of free space that you can check. For other resources ... if you can't acquire them then they weren't released.

like image 200
Jim Balter Avatar answered Oct 17 '22 07:10

Jim Balter