-
May 25th, 2012, 07:52 AM
#1
Thread Starter
New Member
High Memory Utilization of w3p Process
Hi,
I have a created WCF Service and hosted on my server, my server configuration is:
Processor : Intel Core 2 Duo 2.4 Ghz
RAM : 8 GB
HDD : 300 GB
Visual Studio 2008
There are more than 200 users connecting from remote location to this service through window server and upload file on server. This process is running forever and call this function whenever users have something to send on server.
But at any particular time when all users are connected and uploading the file through this service my w3p process uses high memory and private memory utilization goes to 2.3 GB and more.
Intially my server was having 4 GB of RAM but due to above issue I have to upgrade my RAM to 8 GB because when Private memory utilization goes beyond 2.3 GB my server stop respondings and all other my application on this server hangs up.
Below is my code function of WCF service to uoload file. please help to optimize this and suggest ways by which I can free resources explicitly.
Code:
public static void UploadFile(RemoteFileInfo fileRequest, String CreateFilePath)
{
try
{
int chunkSize = 2048;
byte[] buffer = new byte[chunkSize];
using (System.IO.Stream Stream = new System.IO.MemoryStream
(fileRequest.FileByteStream))
{
using (System.IO.FileStream writeStream = new System.IO.FileStream (CreateFilePath, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write))
{
do
{
// read bytes from input stream
int bytesRead = Stream.Read(buffer, 0, chunkSize);
if (bytesRead == 0) break;
// write bytes to output stream
writeStream.Write(buffer, 0, bytesRead);
} while (true);
writeStream.Close();
}
}
GC.GetTotalMemory(true);
}
catch (Exception)
{
throw;
}
}
-
May 30th, 2012, 02:39 PM
#2
Re: High Memory Utilization of w3p Process
Are there huge files uploaded? That could cause such high memory usage. And I have seen in when a using a backgroundthread that call a wcf function.
You could use a memory-profiler to see "where the memory goes"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|