Results 1 to 2 of 2

Thread: High Memory Utilization of w3p Process

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    1

    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;
                }
            }

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    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"
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width