码迷,mamicode.com
首页 > 移动开发 > 详细

malloc without free, what happens?

时间:2014-09-16 07:03:00      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   for   div   on   c   new   

It‘s per-process. Once your process exits, the allocated memory is returned to the OS for use by other processes (new or existing).

To answer your edited question, there‘s only a finite amount of memory in your machine. So if you have a memory leak, then the major problem is that the memory isn‘t available for other processes to use. A secondary, but not negligible, effect is that your process image grows, you‘ll swap to disc and performance will be hit. Finally your program will exhaust all the memory in the system and fail, since it‘s unable to allocate any memory for itself.

It‘s arguable that for a small process with a short lifetime, memory leaks are tolerable, since the leaked memory will be small in quantity and short-lived.

Take a look at this resource, for possibly more info than you‘ll ever need. What we‘re discussing here is dynamic or heap allocation.

malloc without free, what happens?

标签:http   io   os   ar   for   div   on   c   new   

原文地址:http://www.cnblogs.com/miaoz/p/3974111.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!