vb.net中的内存释放 [英] Memory release in vb.net

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

问题描述



我们在创建的对象中有一个维护项目而没有清除



Hi,
we have a maintainence project in that created objects and not cleared

Dim Ds As New DataSet()





Ds未清除

是否会降低性能

我们有很多对象这样的



提前谢谢



Ds not cleared
does it degrades the performance
we have many objects as such

Thanks in advance

推荐答案

嗯,不 - 可能不是。很难判断它是否存在,但它不应该。 DataSet未实现IDisposable( MSDN [ ^ ])所以它不应该使用任何其他系统资源比内存,所以每个实例将占用空间,但前提是你不保留对它们的引用(即你允许引用超出范围,或明确覆盖它们而不是不必要地将它们保持在类级别)垃圾收集器应该在需要时开始并清除它们。这将释放内存,因此使用大量内存不会显着降低性能。



但是......如果你创建了很多很多,使用一个小的将它们丢弃并丢弃它们可能效率不高 - 可能有更好,更快捷的方法来处理您的数据 - 但只有您可以通过代码告诉它。
Well, no - probably not. It's difficult to tell if it is, but it shouldn't. DataSet does not implement IDisposable (MSDN[^]) so it shouldn't use any system resources other than memory, so each instance will occupy space, but provided that you don't keep references to them (i.e. you allow references to go out of scope, or explicitly overwrite them rather than keeping them at a class level unnecesarily) the garbage collector should kick in when needed and clear them all up. This will free the memory so using lots of them shouldn't degrade performance noticeably.

But...if you are creating lots and lots of them, using a tiny bit and discarding them, it may not be efficient - there may be better, quicker ways to process your data - but only you can tell that from your code.


这篇关于vb.net中的内存释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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