Home > Back-end >  C new allocated memory is not released
C new allocated memory is not released

Time:09-27

C + + new allocated memory is not released, the operating system will recycle this part of the memory?

CodePudding user response:

Will, program exits, recycling

CodePudding user response:

Will, but if you don't call the delete release the memory, even if the object because the scoping rules and object is released, the source of the life cycle in free storage space dynamically allocated variables or structure will continue to exist,
So, that is to say, actually will not be able to access the free storage structure in space, will lead to a memory leak,
Leaked memory will be in the program of internal shall not use the entire life cycle,
In the fourth chapter above reference to c + + Primer Plus compound type of print
Specific can baidu about "stack, heap and memory leaks" relevant content oh ~

CodePudding user response:

Naturally, the program ended, the system automatically recycling, this is not a real program, the software will help you to end the program, or you will
The most standard is recommended to use the delete free memory space, in case of a one thousand
There are some software also don't necessarily have the function, the best will delete directly

CodePudding user response:

New and delete in pairs best use, ensure no leakage of memory, otherwise easy to cause abnormal program, you can use valgrind to inspect
  • Related