Memory leak when closing a program with x

Perhaps this is a stupid question, but if I create a console application that dynamically creates an object, etc., I will definitely release memmory when I exit. What happens if the user closes the application using the "x" button in the window? will there be memory patches, and if so, how can this be prevented?

+1
source share
3 answers

No, there will be no memory leaks.

When the user closes your application, the process in which your application is running ends. Once the process is completed, the operating system (OS) simply restores all the memory that it has allocated for this process.

Note that it doesn’t matter for the OS whether the memory leak was an application or not, it’s just a recovery of what it assigned to the process.

+2
source

The application will just be killed. In this case, memory leaks do not actually occur, since the OS does the cleanup for you.

0
source

If you do not have built-in (or buggy) O / S, you do not need to do anything.

If you have built-in (or buggy) O / S, you need to strictly monitor all memory allocations and ensure there is corresponding free. For O / S buggies, you must additionally file a complaint with the O / S provider

0
source

All Articles