1. 什么是内存泄漏(memory leak)?
       指因为疏忽或错误造成程序未能释放已经不再使用的内存的情况。内存泄漏并不是指内存在物理上的消失,而是应用程序分配某段内存后,因为设计错误,失去了对该段内存的控制,因而造成了内存的浪费。 

A memory leak is a particular type of unintentional memory consumption by a computer program where the program fails to release memory when no longer needed. This condition is normally the result of a bug in a program that prevents it from freeing up memory that it no longer needs.This term has the potential to be confusing, since memory is not physically lost from the computer. Rather, memory is allocated to a program, and that program subsequently loses the ability to access it due to program logic flaws. 

2. 对于C和C++这样的没有Garbage Collection 的语言来讲,我们主要关注两种类型的内存泄漏:堆内存泄漏(Heap leak)。对       内存指的是程序执行中依据须要分配通过malloc,realloc new等从堆中分配的一块内存,再是完毕后必须通过调用相应的 free或者delete 删掉。假设程序的设计的错误导致这部分内存没有被释放,那么此后这块内存将不会被使用,就会产生Heap Leak. 

       系统资源泄露(Resource Leak).主要指程序使用系统分配的资源比方 Bitmap,handle ,SOCKET等没有使用对应的函数释放掉,导致系统资源的浪费,严重可导致系统效能减少,系统执行不稳定。  

3. 怎样解决内存泄露?

       内存泄露的问题其困难在于1.编译器不能发现这些问题。2.执行时才干捕获到这些错误,这些错误没有明显的症状,时隐时现。              

4.对于手机等终端开发用户来说,尤为困难。以下从三个方面来解决内存泄露:

       第一,良好的编码习惯,尽量在涉及内存的程序段,检測出内存泄露。当程式稳定之后,在来检測内存泄露时,无疑添加了排除的困难和复杂度。

       使用了内存分配的函数,要记得要使用其想用的函数释放掉,一旦使用完成。

       Heap memory:

              malloc\realloc ------  free

              new \new[] ----------  delete \delete[]

              GlobalAlloc------------GlobalFree 

       要特别注意数组对象的内存泄漏

              MyPointEX *pointArray =new MyPointEX [100];

       其删除形式为:

              delete []pointArray 

       Resource Leak :对于系统资源使用之前要细致看起用法,防止错误使用或者忘记释放掉系统资源。