z***e 发帖数: 5393 | 1 照几个说法的话,Windows下面不管是用TerminateProcess()强行中止程序也好,还是
自然地return也好,process所使用的一切内存都会被release,那么这样子就不应该有
memory leak啊?
就算用ExitProcess(),也只是可能destructor不被调用,最终process所占用的空间仍
然会在结束后回收?
实在不清楚。 | y*****i 发帖数: 2 | 2 Process都终结了,没有memory leakage
memory作为process的一种资源, process结束时全都释放了
【在 z***e 的大作中提到】 : 照几个说法的话,Windows下面不管是用TerminateProcess()强行中止程序也好,还是 : 自然地return也好,process所使用的一切内存都会被release,那么这样子就不应该有 : memory leak啊? : 就算用ExitProcess(),也只是可能destructor不被调用,最终process所占用的空间仍 : 然会在结束后回收? : 实在不清楚。
| z***e 发帖数: 5393 | 3 那这样子说起来的话,windows下根本就不会有memory leak的问题啊?
例如我写一个:
int main()
{
char* buf=new char[1024];
}
然后运行,这个process结束后heap内存也有系统自动回收,就没有memory leak?
【在 y*****i 的大作中提到】 : Process都终结了,没有memory leakage : memory作为process的一种资源, process结束时全都释放了
| z***e 发帖数: 5393 | 4 又google了一下。
实际上malloc/new是通过win32的HeapAllocate之类的分配heap内存,而这个heap内存
实际上是windows通过类似memory pool之类的东西实现的,总之process结束后整个
process heap全部一笔勾销,所以其实不用delete也不会有memory leak.
是么?
又有提到说如果load了DLL,那么如果TerminateProcess,DLL里面可能会有leak,Why
?因为DLL是另外一个process memory space? | t****t 发帖数: 6806 | 5 你能不能说说现在哪个OS不是这样……
【在 z***e 的大作中提到】 : 那这样子说起来的话,windows下根本就不会有memory leak的问题啊? : 例如我写一个: : int main() : { : char* buf=new char[1024]; : } : 然后运行,这个process结束后heap内存也有系统自动回收,就没有memory leak?
| c****e 发帖数: 1453 | 6 程序不会.DLL是另外一个进程,不free library, 计数不为零, 不会释放的. | z***e 发帖数: 5393 | 7 right right, every OS has its memory pool or whatever for applicaiton to
allocate memory and then put it back.
If so, why do we have the experience that the windows becomes slow after
using it for a while. e.g. When you first start windows, the used memory is
around 400Mb, then you play WOW, use Visual Studio, open bunch of browsers,
and you terminate all the applications (using task manager). Supposingly the
memory usage should be back to the initial phase which is around 400Mb, but
in most cas
【在 t****t 的大作中提到】 : 你能不能说说现在哪个OS不是这样……
| k*k 发帖数: 508 | 8 not only those programs run in the system bah..
is
,
the
but
【在 z***e 的大作中提到】 : right right, every OS has its memory pool or whatever for applicaiton to : allocate memory and then put it back. : If so, why do we have the experience that the windows becomes slow after : using it for a while. e.g. When you first start windows, the used memory is : around 400Mb, then you play WOW, use Visual Studio, open bunch of browsers, : and you terminate all the applications (using task manager). Supposingly the : memory usage should be back to the initial phase which is around 400Mb, but : in most cas
| t****t 发帖数: 6806 | 9 那是早年间的事了吧,现在的windows没那么差
我在公司和家里的机器都是几个月不重启一次的
早年间windows对资源的管理有不少毛病,现在就算还有毛病也比较轻微了。
不过firefox和ie7都吃内存吃得厉害。firefox我几天就手动重启一次。ie7几天就自动
垮一次。
is
,
the
but
【在 z***e 的大作中提到】 : right right, every OS has its memory pool or whatever for applicaiton to : allocate memory and then put it back. : If so, why do we have the experience that the windows becomes slow after : using it for a while. e.g. When you first start windows, the used memory is : around 400Mb, then you play WOW, use Visual Studio, open bunch of browsers, : and you terminate all the applications (using task manager). Supposingly the : memory usage should be back to the initial phase which is around 400Mb, but : in most cas
| k*k 发帖数: 508 | 10
~~~~~~~~~ this may be a memory management strategy. :)
firefox, //sigh, I really really hate its idea of caching everything.
【在 t****t 的大作中提到】 : 那是早年间的事了吧,现在的windows没那么差 : 我在公司和家里的机器都是几个月不重启一次的 : 早年间windows对资源的管理有不少毛病,现在就算还有毛病也比较轻微了。 : 不过firefox和ie7都吃内存吃得厉害。firefox我几天就手动重启一次。ie7几天就自动 : 垮一次。 : : is : , : the : but
| m******t 发帖数: 2416 | 11
is
,
the
but
The OS may have cached more files in the memory, or some of the services are
started. Just because it doesn't go back to around 400Mb, it doesn't mean
there are memory leaks.
【在 z***e 的大作中提到】 : right right, every OS has its memory pool or whatever for applicaiton to : allocate memory and then put it back. : If so, why do we have the experience that the windows becomes slow after : using it for a while. e.g. When you first start windows, the used memory is : around 400Mb, then you play WOW, use Visual Studio, open bunch of browsers, : and you terminate all the applications (using task manager). Supposingly the : memory usage should be back to the initial phase which is around 400Mb, but : in most cas
| y*****i 发帖数: 2 | 12 you need to learn more about the operating system concepts, I guess | j********g 发帖数: 88 | 13 操作系统的资源不是只有内存而已
不然.Net里面不会有IDisposable这个接口存在 |
|