如何减少内存泄漏(Commit memory Size)? [英] How to reduce Memory Leak (Commit memory Size) ?

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

问题描述

你好,

在我的应用程序中,当我尝试用大量记录(大约2十万)填充数据集的表时,它给出了内存不足异常的错误.

我认为是由于虚拟内存大小增加(任务管理器中的Commit大小正在增加).

那么如何防止这种记忆链接?

在此先感谢.

问候,
Yogesh

拉赫(Lakh)-维基百科,免费百科全书:拉克(lakh)或拉克(lac)是印度编号系统中的一个单位,等于十万个-OriginalGriff [/edit]

Hello ,

In my application when i try to fill dataset''s table with huge amount of records (2 Lakh Approx.) it gives error of outofmemory Exception .

I think it is Due to increasing Virtual memory size (Commit size is increasing in Task Manager) .

So how to prevent this memory link ?

Thanks in Advance .

Regards,
Yogesh

[edit]Lakh - Wikipedia, the free encyclopedia: A lakh or lac is a unit in the Indian numbering system equal to one hundred thousand -OriginalGriff[/edit]

推荐答案

您真的一次需要所有这些记录吗?
对它们进行分页或从源筛选它们是否比一次尝试转移那么多记录更好?
考虑一下:如果您要填充PC内存,试图将那么多数据填充到DataTable中,请考虑将在与服务器的网络链接上使用多少带宽.现在,假设有10个人试图做同样的事情.同时.或者想象一下,当老板说:正确,将数据库移到Web上..."
Do you really need all those records at once?
Would it not be better to page them, or filter them at source rather than trying to transfer that many records in one go?

Think about it: if you are filling up your PC memory trying to stuff that much data into a DataTable, think how much bandwidth you will be using on the network link to the server. Now imagine there are 10 of you, trying to do the same thing. At the same time. Or imagine when your boss says: "Right, move that database onto the Web..."


我建​​议如果不能避免的话,建议不要将大量数据放在第一位.有什么原因不能以某种方式分页或拆分数据?

一个进程的可用内存量很复杂,但是根据您的设置,它可能低至1.4GB.您的记录只需达到大约8K即可达到此限制(假设我正确完成了自己的计算),因此您可能需要考虑更好的内存管理.
I''d suggest not loading this much data in the 1st place if it can be avoided. Is there any reason you can''t page or break up the data somehow?

The amount of available memory to a process is complicated, but it may be as low as 1.4GB depending upon your setup. Your records would only need to be about 8K to hit this limit (assuming I''ve done my calcs correctly) so you may need to consider better memory management.


首先,您"重新拉回一堆数据并将其存储在内存中,所以这实际上并不是内存泄漏,您只是在使用所有可用的内存.

以下是解决该错误的一些建议:
1.减少要带回的行数.您可能只需要带回的200k记录中的一小部分.

2.减少要带回的列数.您正在执行select * from table1还是仅撤回需要的列?

3.使用DataReader填充自定义数据对象,而不使用DataTable.数据表会带来很多开销.
First, you''re pulling a pile of data back and storing it in memory, so this isn''t really a memory leak, you''re just using all the available memory.

Here are some suggestions for working around the error:
1. Reduce the number of rows you are bringing back. Chances are you only need a small subset of the 200k records you''re bringing back.

2. Reduce the number of columns you are bringing back. Are you doing a select * from table1 or are you only pulling back the columns you''ll need?

3. Use a DataReader to populate custom data objects instead of using the DataTable. DataTables come with a lot of overhead.


这篇关于如何减少内存泄漏(Commit memory Size)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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