Home > Back-end >  Design of a class of "garbage collection management", is at the end of the program is runn
Design of a class of "garbage collection management", is at the end of the program is runn

Time:09-17

Design of a class of "garbage collection management", is at the end of the program is running automatically release with new has not yet been allocated by the delete the interpretation of the basic dynamic memory, avoid the "memory leak",

CodePudding user response:

Overloading new and delete

CodePudding user response:

At the end of the program is running automatically release with new has not yet been allocated by the delete the interpretation of the dynamic memory
Your operating system has the function of the ~

CodePudding user response:

Memory leak is general discussion program run "manger" hog the memory meaningless behavior, but also constantly cycle to occupy one toilet,

CodePudding user response:

https://blog.csdn.net/sinat_34967445/article/details/77365758 have a look at the principle of hooks on the underlying function, their implementation

CodePudding user response:

Their implementation class destructor, or use smart Pointers all pointer variable in the class

CodePudding user response:

reference 4 floor yiyefangzhou24 response:
https://blog.csdn.net/sinat_34967445/article/details/77365758 have a look at the principle of hooks on the underlying function, their implementation

There is source code

CodePudding user response:

Didn't seem to understand the concept of "memory leak",
Runtime cache, memory is the process to end the total memory will naturally be all recycled, the so-called "memory leak" refers to the process you are still in the running, in the meantime you have lost a allocated heap memory address, lead to the heap memory occupied by all the time, but you will never be able to access it, this is a waste of resources, if things continue to accumulate memory leaks, then your progress sooner or later face without memory is available,

CodePudding user response:

Similar to smart Pointers can own design template class, realize the destructor, operator overloading pointer,
  • Related