关闭

Memory leak

标签: java
180人阅读 评论(0) 收藏 举报
分类:

Memory leak

From wiki:

Memory leaks are a common error in programming, especially when using languages that have no built in automatic garbage collection, such as C and C++. Typically, a memory leak occurs because dynamically allocated memory has become unreachable. The prevalence of memory leak bugs has led to the development of a number of debugging tools to detect unreachable memory.

内存泄漏的例子:

When a button is pressed:
 Get some memory, which will be used to remember the floor number
 Put the floor number into the memory
 Are we already on the target floor?
   If so, we have nothing to do: finished
   Otherwise:
     Wait until the lift is idle
     Go to the required floor
     Release the memory we used to remember the floor number

在If so, we have nothing to do的时候会发生内存泄漏,因为这里分配的内存我们没有释放掉。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:104732次
    • 积分:2746
    • 等级:
    • 排名:第14822名
    • 原创:148篇
    • 转载:31篇
    • 译文:24篇
    • 评论:15条
    文章分类
    最新评论