问题:记忆(私人工作集) [英] What to ask: Memory (private working set)

查看:66
本文介绍了问题:记忆(私人工作集)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道内存(私人工作集)对Windows服务的性能是否有任何影响。



我用C#开发了一个Windows服务程序。

基本上它的作用是,读取一个非结构化的文本文件,然后将其转换为结构化文本文件。

文件大小为每个文件1GB到2GB,多线程。



正如我所说,任务管理器的内存(私有工作集)越高;它去了,读取和写入文件的程序越差。



我已经进行了故障排除并以任何方式重新编程。仍然没有运气

对上述任何评论,非常感谢。



谢谢

Hi guys,
I was wondering if there is any impact of the Memory (private working set) towards the performance of the windows services.

I developed a Windows Service program in C#.
Basically what it does is, reading an unstructured text file and then converting it to a structured text file.
File size ranging 1GB to 2GB per file, in multi-threaded.

As what I noted, the higher the Memory (private working set) from the Task manager; it goes, the poorer the program to read and write file.

I already troubleshooting and recode the program in any ways. Still no luck
Any comments to the above, very much appreciated.

Thanks

推荐答案

我建​​议你使用.NET提供的StreamReader和StreamWriter



你需要做的就是逐行读取你的输入文件,格式化它并将其重定向到输出文件。



这将使您能够有效地使用内存,并且,当您处理大文件大小时,它将为您提供更好的性能。



但是,您可能需要更改格式化算法以逐行工作。
I would suggest you to use StreamReader and StreamWriter provided by .NET

All you need to do is read your input file line by line, format it and redirect it to the output file.

This will enable you to use your memory efficiently and also, it will provide you better performance as you are dealing with large file sizes.

However, you might need to change your algorithm of formatting to work on line-by-line scenario.


您仅限于系统和操作系统的可用物理内存量,如果达到上限,操作系统会将未使用的内存换成磁盘,这将使您的应用和系统速度变慢。



如果您可以加载并处理文件,那么请先将内容加载到内存中。
You are limited to the amount of available physical memory of your system and OS, if you reach the upper limit the OS will swap out unused memory to disk which will make your app and system slow down.

If you can chunk load and process your files then do that instead of loading everything into memory first.


我发现了问题。

这是由于StringBuilder将字符串收集为streamreader代码的底部。



删除之后,速度非常棒...



非常感谢帮助的人:)
I have found the problem.
It is due to StringBuilder that is collection the strings as the bottom of the streamreader code.

After removing it, the speed is superb...

Many thanks guy for helping :)


这篇关于问题:记忆(私人工作集)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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