English 中文(简体)
同一目录中拥有数百万份其他档案的单一档案(仅阅读)似乎消耗了很多记忆。
原标题:Opening a single file (read only) with millions of other files in the same directory seems to consume way to much memory
  • 时间:2010-07-22 18:42:19
  •  标签:
  • c#
  • .net

我有一个Windows服务,正在从包含数百万其他档案的名录中检索一些选定的文档。 这项服务每小时停播一次。 这从来就没有发生,因此,它感到有些资源没有得到妥善处置。 但我想到的是,该溪流正在妥善处置。

using (FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read))
{
  //deserializes the file with a binary formatter
}

该名录本身被打上了标语,因此我也想知道这是否助长了这一问题。

谁能解释这种明显的记忆泄露的原因?

最佳回答

I agree that the problem probably has little to do with your .net code and more to do with the underlying filesystem. This question may be helpful.

问题回答

这几乎肯定是因为翻了数百万份档案。 很可能有一个表格,必须加以研究,以压缩数据,而且表格将随着文件夹中文件的数量而增加。 破坏档案的行为是造成你问题的原因。

你们是否为你们的问题找到了适当的位置?

如果有已知的档案名称,除了从档案系统管理类似目录之外,不应有排位。 你不应在你的法典中引起记忆问题或过分的相对性。

您是否将档案目录或查阅档案列入服务法典?

A "directory that contains millions of other files" does not sound healthy to me. It might be that there is no memory leak, just that the operation requires more memory than is available ...





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签