C#& GC [英] C# & GC

查看:71
本文介绍了C#& GC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我创建应用程序,将巨大的XML文件(~150 Mb)转换为CVS文件。

我面临着奇怪的问题。在20000之后1秒内解析前1000行

每秒(我应该解析~2) 500 000行)。


对我来说它看起来像GC问题,但我不知道如何解决它:(


任何欢迎提出想法。


-

谢谢,

Maxim

Hi,

I create application which transform huge XML files (~ 150 Mb) to CVS files.
And I am facing strange problem. First 1000 rows parsed in 1 sec after 20000
rows speed down to 100 rows per sec, after 70000 rows speed down to 20 rows
per sec ( I should parse ~ 2 500 000 rows).

For me it looks like a GC problem, but I have no Idea how to fix it :(

Any ideas are welcome.

--
Thanks,
Maxim

推荐答案

Maxim Kazitov写道:
Maxim Kazitov wrote:
我创建的应用程序将巨大的XML文件(~150 Mb)转换为CVS文件。
我面临着奇怪的问题问题。在每秒20000行速度下降到100行之后,在1秒内解析前1000行,在每秒70000行速度下降到20行之后(我应该解析~2 500 000行)。 br />
对我来说它看起来像GC问题,但我不知道如何解决它:(
I create application which transform huge XML files (~ 150 Mb) to CVS files.
And I am facing strange problem. First 1000 rows parsed in 1 sec after 20000
rows speed down to 100 rows per sec, after 70000 rows speed down to 20 rows
per sec ( I should parse ~ 2 500 000 rows).

For me it looks like a GC problem, but I have no Idea how to fix it :(




如果你通过阅读进行转换将整个文件转换为XML文件的表示形式然后生成CVS,你是b / b
施加严重的记忆压力。如果你可以读取一个XML元素并且

写一个CVS元素,没有每次迭代添加(很多,如果有的话)

到你的工作集,你可能会更快。


如果你确实需要构建整个文件的表示,并且每个

XML属性名称和值都是一个不同的字符串,你可以经常保存

a很多interning字符串值,消除重复字符串

值。


这也完全有可能与GC无关。

您所描述的内容与某些代码兼容,这些代码正在走向一个不断增长的链接

列表....


-

www.midnightbeach.com


你好Jon,


我使用XmlTextReader,所以在解析过程中我没有读过所有的XML

我建立小的Xml文档(每行一个XmlDocument),并对每个文档应用一组

XPath。我的代码中有几个Hashtables,但是它们很小。

谢谢,

Max

Jon Shemitz < jo*@midnightbeach.com>在消息中写道

news:42 *************** @ midnightbeach.com ...
Hi Jon,

I use XmlTextReader, so I don''t read all XML in once, during the parsing
I build small Xml Documents (one XmlDocument per row), and apply a set of
XPath''s to each document. I have a couple of Hashtables in my code, but they
pretty small.
Thanks,
Max
"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:42***************@midnightbeach.com...
Maxim Kazitov写道:
Maxim Kazitov wrote:
我创建了将巨大的XML文件(~150 Mb)转换为CVS
文件的应用程序。
我面临着奇怪的问题。在1秒内解析前1000行,然后将每行速度降低到每行100行,在每秒70000行速度降至20行之后(我应该解析~2) 500 000行。

对我来说它看起来像GC问题,但我不知道如何解决它:(
I create application which transform huge XML files (~ 150 Mb) to CVS
files.
And I am facing strange problem. First 1000 rows parsed in 1 sec after
20000
rows speed down to 100 rows per sec, after 70000 rows speed down to 20
rows
per sec ( I should parse ~ 2 500 000 rows).

For me it looks like a GC problem, but I have no Idea how to fix it :(



如果你做这个转换通过将整个文件读入XML文件的表示然后生成CVS,你会产生严重的内存压力。如果你能读取一个XML元素并且编写一个CVS元素,那么每次迭代添加(很多,如果有的话)到你的工作集,你可能会更快。

如果你确实需要构建整个文件的表示,每个

它''也完全有可能这与GC无关。
你所描述的是兼容的le带有一些代码,这些代码正在一个不断增长的链接
列表....


www.midnightbeach.com



您是否在创建XmlDocument或重复使用同一个?你应该确保

,你只是使用相同的一个并将XML字符串加载到

同一个。


我当我经常使用XmlDocument实例时遇到了内存问题。


Maxim Kazitov < MV ***** @ tut.by>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP14.phx.gbl ...
Are you creating an XmlDocument or reusing the same one? You should ensure
that you are simply using the same one and Loading the XML string into the
same one.

I ran into memory issues when I used XmlDocument instances a lot.

"Maxim Kazitov" <mv*****@tut.by> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
嗨Jon ,

我使用的是XmlTextReader,所以我没有一次读取所有XML,在
解析期间我构建了小型Xml文档(每行一个XmlDocument),并应用了一组<每个文档都有XPath。我的代码中有几个Hashtables,但
它们非常小。

谢谢,
Max

" Jon Shemitz" < jo*@midnightbeach.com>在消息中写道
新闻:42 *************** @ midnightbeach.com ...
Hi Jon,

I use XmlTextReader, so I don''t read all XML in once, during the parsing I build small Xml Documents (one XmlDocument per row), and apply a set of
XPath''s to each document. I have a couple of Hashtables in my code, but they pretty small.
Thanks,
Max
"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:42***************@midnightbeach.com...
Maxim Kazitov写道:
Maxim Kazitov wrote:
我创建的应用程序将巨大的XML文件(~150 Mb)转换为CVS
文件。
我面临着奇怪的问题。在1秒内解析前1000行,然后将每行速度降低到每行100行,在每秒70000行速度降至20行之后(我应该解析~2) 500 000行。

对我来说它看起来像GC问题,但我不知道如何解决它:(
I create application which transform huge XML files (~ 150 Mb) to CVS
files.
And I am facing strange problem. First 1000 rows parsed in 1 sec after
20000
rows speed down to 100 rows per sec, after 70000 rows speed down to 20
rows
per sec ( I should parse ~ 2 500 000 rows).

For me it looks like a GC problem, but I have no Idea how to fix it :(



如果你做这个转换通过将整个文件读入XML文件的表示然后生成CVS,你会产生严重的内存压力。如果你能读取一个XML元素并且编写一个CVS元素,那么每次迭代添加(很多,如果有的话)到你的工作集,你可能会更快。

如果你确实需要构建整个文件的表示,每个

它''也完全有可能这与GC无关。
你所描述的是兼容的le带有一些代码,这些代码正在一个不断增长的链接
列表....


www.midnightbeach.com




这篇关于C#&amp; GC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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