如何解决内存泄漏问题 [英] How to solve memory leak issue

查看:76
本文介绍了如何解决内存泄漏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在Windows 7 64位系统上运行应用程序时,我遇到内存泄漏问题,经过一定限制后,我的应用程序崩溃了.
如果我在Windows XP上运行相同的应用程序,则不会发生内存泄漏.但是在Windows 7 64位或Windows 7 32位系统中,内存不断增加.我可以在任务管理器中看到这个.请提出建议.

Hello Everyone,

I am facing memory leak problem while running the application on windows 7 64 bit system and after certain limit my application gets crashed.
If I run the same application on windows XP, then there is no memory leak. But in windows 7 64 bit or windows 7 32 bit system, the memory raise continuously. I can see this in Task manager.Please suggest.

thanks in advance.

推荐答案

在C#中,您不应该发生内存泄漏,因此有两种选择:

1.您使用的组件不是用托管代码编写的.如果您这样做,那就是第一个要看的地方.您是否将所有资源释放到该组件? DataAccess组件(例如OleDb,ADO,ODP等)可能会出现此问题,例如

2.您没有本身"的内存泄漏,但是您一直在不断分配和使用对象.

我很惊讶Windows 7而不是Windows Xp上存在该问题.如果是真正的内存泄漏,我认为这会在两个OS上都发生.在这种情况下,潜在客户可能是两台机器之间的差异:例如. 用户"文件夹.

在不知道您的应用程序做什么的情况下很难说出来.
In C# you shouldn''t have memory leaks, so there are 2 options:

1. You use a component not written with managed code. If you do, that''s the first place to look. Do you release all resources to that component? DataAccess components (like OleDb, ADO, ODP, ...) can have this problem eg.

2. You don''t have a memory leak ''per se'', but you keep assigning and using objects continuously.

I''m surprised the issue is there on Windows 7 and not on Windows Xp. If it was a real memory leak, I would think it occurs on both OS. In this case a lead might be the difference between the two machines: eg. the ''users'' folder.

It''s hard to tell without knowing what your application does.


在代码项目上有很多不错的文章讨论了内存泄漏检测.尝试其中之一,看看是否能给您答案.即使不是上述建议的内存泄漏,您也可能会发现代码中消耗内存最多的部分.
There are quite a few good articles on the code project talking about memory leak detection. Try one of them and see if it gives you any answers. Even if it is not a memory leak as suggested above, you might find a part of your code which consumes the most memory.


这篇关于如何解决内存泄漏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆