After the process finishes, all memory for the process is freed, including memory leaks on the heap.

Source: Internet
Author: User

After the process finishes, all memory for the process is freed, including memory leaks on the heap. The reason is that when the process is finished, the GDT, LDT, and page directories are changed by the operating system, the logical memory is all gone, the contents of the physical memory may still be in but the logical memory has been removed from the LDT and GDT, the page directory table is all destroyed, so the memory will be fully recovered.

This code, I personally think that can be used as an example, not to please more advice:

[C-sharp]View Plaincopy
  1. #include <cstdlib>
  2. using namespace Std;
  3. const static int const_once = 1024*1024*2;
  4. int _tmain (int argc, _tchar* argv[])
  5. {
  6. int *a;
  7. for (int cnt=0;cnt<=10;cnt++)
  8. {
  9. A = new int[const_once];
  10. A[10] = 1;
  11. A[CONST_ONCE-10] = 1;
  12. }
  13. System ("pause");
  14. Exit (0);
  15. return 0;
  16. }

Operation Result:

When you pause:

After:

I this program does not account for hundreds of trillion memory, you can try repeatedly, some people always say that memory leaks until the new start to be recycled, I think this is the DOS ERA, DOS there is no paging fragmented virtual storage of these management, so it will always leak it.

Transferred from: http://blog.csdn.net/x50573750/article/details/6171604

After the process finishes, all memory for the process is freed, including memory leaks on the heap.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.