内存由应用程序使用 [英] Memory Used by applications

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

问题描述

大家好,



我有一个从网站收集数据的应用程序。



这个应用程序可以使用数天,收集的数据保存在数据库和列表中(数据保存在list / datagridview中)。几天之后收集的数据达到数十万行。



现在我想确定,



1 /是列表(汇总所有数据)保存在RAM中?



虽然我很确定它保存在RAM中,我需要确认。



如果是这样的话:



2 /使用这个停止填写清单非常重要approch避免系统内存不足(可能是其他异常)当数据巨大时?



希望你可以枚举一些行动来避免/做什么工作使用消耗大量内存的应用程序。



感谢您的帮助。



*我可以获得如果我有义务,摆脱列表。

Hi all,

I have an application that gathers data from websites.

This app works for days, and the data gathered are saved in database and a list(the data is saved in a list/datagridview). after few days the gatherd data reaches hundreds of thousands of lines.

Now i want to be sure,

1/is the list(contining all the data) is saved in the RAM?

Althought i am pretty sure it is saved in the RAM, i need confirmation.

If it is the case:

2/Its important to stop filling a list using this approch to avoid "System out of memory exception(and maybe other exceptions)" when the data becaome huge?

Hope you can enumerate some actions to avoid/do when working with apps that consume a lot of Memory.

Thanks for you help.

*i can get rid of the list if i am obliged.

推荐答案

List< T>集合存储在RAM中,是 - 您写入数据库的数据不是 - 它会进入磁盘,因此不会丢失。



所以如果你继续添加列表中的项目,然后是,在某些时候你将耗尽内存,你会得到一个例外 - 需要多长时间取决于对象的大小,内存的大小,硬盘上的可用空间和你的系统是32位还是64位。



如果你没有使用这些信息,那就不要不必要地将它存储在List中 - 处理它并得到它当你完成它的时候你的系统已经完成,如果会有很多使用它们,堆管理器可以重新使用内存用于下一个(运气好的话)



如果您将信息用作缓存,为了加快返回数据库并获取它操作,那么您可能希望将其保留在内存中,但您可以考虑添加失效日期并每天清除以释放记忆。虽然不是一个简单的工作!
List<T> collections are storing in RAM, yes - the data you write to the Database is not - that goes to disk so it isn't lost.

So if you keep adding items to the list, then yes, at some point you will run out of memory, and you will get an exception - how long it takes depends on the size of the object, the size of your memory, the free space on your HDD and whether your system is 32bit or 64bit.

If you aren't using the info, then don't store it in the List unnecessarily - Dispose of it and get it out of your system when you are finished with it if there are going to be a lot of them used and the heap manager can re-use the memory for the next one (with a bit of luck)

If you are using the info as a cache, to speed up the "go back to the DB and get it" operation, then you probably want to keep it in memory, but you might consider adding an "expiry date" and purging every day of so to free up memory. Not a simple job though!


列表内容存储在进程虚拟内存中(即物理RAM和磁盘)。

您的存储库应该是数据库,而不是列表。该列表应仅显示所收集数据的一部分(例如,最近的100行)。这样就可以避免异常并使GUI更具响应性。
The list content is stored in the process virtual memory (that is both physical RAM and disk).
Your repository should be the database, not the list. The list should show only a part of the collected data (e.g. the most recent 100 rows). This way you would avoid the exception and make the GUI more responsive.


这篇关于内存由应用程序使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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