我的c#应用程序使用内存不断增加每次点击如何减少 [英] my c# application usage memory is keep increasing every click how to reduce that

查看:673
本文介绍了我的c#应用程序使用内存不断增加每次点击如何减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中创建了一个应用程序。应用程序使用内存每次点击并鼠标悬停在form.how上以减少它。并且内存也会不断增加,甚至每次都激活和停用。

created one application in c#.that application usage memory is keep increasing each and every time click and mouse over on form.how to reduce that.and also memory is keep increasing even form activated and deactivated each time.

推荐答案

减少?如果你有内存泄漏,你不应该减少它。你应该完全从这个基本缺陷中保存你的应用程序。



现在,我不确定你真的拥有它。我怀疑你正在看过程管理器。这是观察内存使用情况的绝对不可靠的方法。请忽略它。



有些事情是管理内存泄漏是不可能的。事实并非如此,但问题甚至是如何定义内存泄漏。是的,泄漏仍然是可能的,但它们似乎是从根本上错误的设计,或只是一个代码设计的结果。你可以很好地防止意外的内存泄漏。



我在过去的答案中详细解释了这个问题,请参阅:

WPF数据绑定中的内存泄漏 [ ^ ],

MDI表单中的内存管理 [ ^ ],

摆脱导致内存不足的公共静态列表的最佳方法 [ ^ ](考虑使用弱引用),

推迟循环中的可变内容会导致内存泄漏? [ ^ ],

Garbage collectotion负责所有内存管理 [ ^ ]。



-SA
Reduce? If you have a memory leak, you should not reduce it. You should save your application from this fundamental flaw completely.

Now, I'm not sure you really have it. I suspect you are looking at Process Manager. This is absolutely unreliable method of observing the memory usage. Just disregard it.

Some thing that it's impossible to have a leak of managed memory. This is not true, but the problem is even how to define what a memory leak is. Yes, leaks are still possible, but they rather appear as the result of fundamentally wrong design, or just one code design but. You are pretty well protected from accidental memory leaks.

I explain this matter in detail in my past answers, please see:
Memory leak in WPF DataBinding[^],
Memory management in MDI forms[^],
Best way to get rid of a public static List Causing an Out of Memory[^] (consider using weak references),
deferring varirable inside the loop can cuase memory leak?[^],
Garbage collectotion takes care of all the memory management[^].

—SA


使用IDisposable并处理我们需要的对象。
Use IDisposable and dispose the object wehrever required.


这篇关于我的c#应用程序使用内存不断增加每次点击如何减少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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