Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Tomas Takac 21-May-15 8:12am    
Are you reading the whole file into memory for processing?
Mercurius84 23-May-15 3:59am    
nope. it is
chunk by chunk
I noticed i have no issue if reading one file.
but if on multi threads my window service program screw. poor performance.
I tried writing similar code on vbs
mean while my window service executive these vbs in multi thread.
suprisingly result is so way greater than before

im looking into that solution

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.
 
Share this answer
 
Comments
Mercurius84 21-May-15 8:35am    
My machine is have 150GB of memory it should sufficient enough to perform heavy duty tasks.

However, my application already using the said function

anyway to increase the upper limit or any suggested solution?
Thanks
Richard Deeming 21-May-15 9:11am    
Is your service running as 64-bit or 32-bit?
Mercurius84 21-May-15 9:33am    
it is running on 64 bit
windows server 2012
Richard Deeming 21-May-15 9:38am    
But is the process running as a 64-bit process?

Check in the Task Manager - does it have "(32 bit)" after the name in the "Processes" view?
Mercurius84 21-May-15 10:29am    
nope at all
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.
 
Share this answer
 
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 :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900