Solved

w3wp.exe eats all memory in IIS usin Response.BinaryWrite

Posted on 2006-11-16
5
2,090 Views
Last Modified: 2007-12-19
I have this site, written in ASP which makes intensive use of Response.BinaryWrite, this is the code mostly used (Jscript):

  var rs = cn.execute(sqlQuery)
  var pos = 0;
  var binMem = rs(0); // data is in first field of recordset

  var stream = Server.CreateObject("ADODB.Stream");
  stream.Type = 1 //adTypeBinary
  stream.Open();
              
  Response.ContentType = this.getContentType();
  Response.AddHeader("Content-Disposition", "inline;filename=\"" + filepath + "\"");
  Response.Buffer = false;
  stream.Write(binMem.Value);
  stream.Position = 0;
  var buffer = (16 * 1024);
                
  while (!stream.EOS)
  {
    Response.BinaryWrite(stream.Read(buffer));
  }
               
  stream.Close();
  try { rs.close(); rs=null; dbe.close(); dbe=null; } catch (e) {}
             
After a few hours the w3wp.exe eats all the system memory (about 1,3Gb) and w2k3 starts paging, which cause IIS to start responding very slowly.

I have read there's a fix from microsoft here:
http://support.microsoft.com/kb/916984

but i have also read that it doesn't completely solve the problems because one of the side effects of applying the fix is that IIS hangs up occasionally.

It would be nice to hear from someone that streams large files using Response.BinaryWrite without having those problems, and to know how he/she does it. I was wondering if using small reads from the record and small writes to the stream could avoid this problem.

0
Comment
Question by:cip
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:AndresM
ID: 17958403
The KB says: "If you set the VectorSendThrottleLimit subkey to a value that is less than the amount of data that an ASP page sends to a client, IIS stops responding (hangs). For example, if you set the VectorSendThrottleLimit subkey to 1000, any ASP page that transfers more than 1000 bytes is not dispayed in the client browser. Additionally, the IIS thread that handles the request is blocked until you restart the IIS service"

So, you should configure VectorSendThrottleLimit with a value grater than the biggest response you could have.

But, I am not sure, I think you can chunk the response, see if this thread helps:

http://groups.google.com.ar/group/microsoft.public.inetserver.asp.general/browse_thread/thread/d0b57f3543749c56/30874979435cce0c?lnk=st&q=asp+chunks++Response.BinaryWrite&rnum=4&hl=es
0
 
LVL 1

Author Comment

by:cip
ID: 17960508
Thanks AndresM.

It's not clear to me how much a good value for VectorSendThrottleLimit should be. What is not clear is the how much is "the amount of data that an ASP page sends to a client". Does this mean a single call to binaryWrite or the data from the first Response.binarywrite to the end of the page.

We stream files several tens of mb large, does this mean we need to set VectorSendThrottleLimit to something like tens of mb? Wouldn't this bring up the problem again 'cause tens of mb are queued so we're there again.


0
 
LVL 10

Accepted Solution

by:
AndresM earned 500 total points
ID: 17964363
I don't know. If you can, you should make some tests with VectorSendThrottleLimit, and see what happens. I couldn't find information about experiences, just this link...
http://support.softartisans.com/Forums/ShowPost.aspx?PostID=1808
0
 
LVL 1

Author Comment

by:cip
ID: 19057042
Just for the records, buffering the data in a loop sending them to the client in small chunks seems to have improved performances. During the loop I also check if the client is still connected using Response.IsClientConnected.

Here is some sample code about how to read blobs in small chunks:
http://support.microsoft.com/kb/317034/en-us

I have accepted AndesM answer giving him a B since he has been of some help suggesting to chunk the response.

thanks
fc
0
 
LVL 1

Author Comment

by:cip
ID: 19057061
Got aware I gave AndesM a C instead of a B, my fault, if an administrator is following can it please change it to a B?

Thanks
fc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now