Might be a stupid question, but if I create a console-application that dynamicly creates object and such, I make sure to free the memmory at shutdown. What happens if a user closes the application with the "x" button on the window? will there be memoryleaks and if so, how do i prevent it?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Unless you have an embedded (or buggy) O/S you don't need to do anything.
If you do have an embedded (or buggy) O/S, you need to rigorously keep track of all your memory allocations and ensure there's a corresponding free. For a buggy O/S, you should additionally complain to the provider of said O/S
No, there won't be any memory leaks.
When a user closes your application the process in which your appication runs gets terminated.Once a process gets terminated, the Operating System(OS) simply reclaims all the memory it had allocated to the process.
Note that for an OS there is no importance whether memory was leaked by the application or not it is simply reclaiming what it allocated to the process.
The application will simply be killed. In this case, memory leaks don't really happen since the OS do the cleanup for you.