• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

Memory leak

Hello all,

I'm running IIS 6.0 on Win2K3.

The script below pulls an image out of my (Access) database, I use the asppainter object to set the quality and then I use the binarywrite method to send it to the client's browser. After I run it, the memory usage of the w3wp.exe process increases with about 300KB and it doesn't decrease again. Since this page is called in a loop to display a lot of images the memory increases very fast.

<!--#include file="../../parameters.asp"-->
<%

DIM bdata
DIM mypic

 STILLID = Request.Querystring("STILLID")

 SQL_STRING = "select STILLDATA from STILLS WHERE STILLID="&STILLID&";"
 
 DSN_CONN_STRING=dbkoppeling()
 set DB_CONN=server.createobject("ADODB.Connection")
 DB_CONN.Open DSN_CONN_STRING
 Set RS = Server.CreateObject("ADODB.Recordset")

 RS.Open SQL_STRING, DB_CONN, adOpenStatic, adLockOptimistic, adCmdText
  If Not RS.EOF Then
   If Not IsNull(RS("STILLDATA")) Then
      Set pic = CreateObject("ASPPainter.Pictures.1")
      mypic = RS("STILLDATA")
      pic.LoadStream (mypic)
      pic.SetJpegQuality 50
      pic.SetFormat 1
      bdata = pic.SaveToStream

      Response.ContentType = "image/jpeg"
      Response.BinaryWrite bdata

      mypic = ""
      bdata = ""

      pic.Destroy
      pic.DestroyALL
      Set pic=Nothing
      Set mypic = Nothing
      Set bdata = Nothing
   End If
  End If

 RS.Close
 Set RS = Nothing
 DB_CONN.Close
 Set DB_CONN=Nothing

%>

Any ideas?
0
EyeContact
Asked:
EyeContact
  • 3
  • 2
1 Solution
 
ajaikumarrCommented:
Hai,

Try to convert these code inside an VB dll and run it as component services.

Bye
Ajai
0
 
EyeContactAuthor Commented:
Hi Ajai,

I have no idea how to do that.

Why are you suggesting this? If this can be done in plain and simple asp, why would I need to make a dll?

EC.
0
 
deighcCommented:
One very simple thing to try (which I doubt will make alot of difference) is to turn buffering off. That means that binary data will be sent to the client immediately rather than when the whole page has finished executing. Just add this line at the top of your page:

Response.Buffer = false

Secondly, I wouldn't do this:

bdata = pic.SaveToStream
Response.BinaryWrite bdata

because you're copying the binary data into another variable before writing it out to the browser. This is completely unnecessary and only increases memory usage. Just use:

Response.BinaryWrite pic.SaveToStream

And one more thing: do you absolutely have to use the image component? All you're doing is setting the image quality. I guess you're doing this to make the output images smaller. Fair enough. But again, this only increases memory usage on your server. The absolute best option in terms of performance would be to write the binary data directly to the client from the database and bypass the image component altogether.

And getting a bit off topic...

You'll no doubt get lots of people asking you why you store the image data in a DB table rather than as a file on the file system. And this is good question :-) Do you really need to do this? This will make your DB grow enormously which with Access in particular is never a good thing.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
EyeContactAuthor Commented:
Hello deighc,

Thanks a lot for your detailed description. Based on your advise I did some further testing and I found out that it is indeed the asppainter component that is causing the memory leak.

I'll tell you a little more of what I am doing here.

Users are uploading powerpoint presentations into my web application. I save the slides as TIF images in the database. Then on the next page, the user gets an overview of all slides (this is the part described above) and he can set times for each slide. The last step is to create an MPEG movie from the TIF images. After that the images will usually be deleted by the user from the database (unless he's not happy with the result (timing..) then he can make a new MPEG).
The TIF files are obviously too big to send to the client, therefor I'm using the asppainter component to make the page load time acceptable.

I will contact the creator of the component and see if he/they know how to fix the leak.
If not, can you advise me another component or workaround?

EC.
0
 
deighcCommented:
I'm not familiar with ASPPainter so I can't provide you with help or suggestions there. But I've had good luck with ASP Image from Server Objects:

http://www.serverobjects.com/products.htm

(scroll down the page a bit)

But, as you've already suggested, I would contact the creators of your current component first since you've probably already given them some $$$.

It's hard to think of a way of breaking up your required functionality into different steps so as to avoid your problem. If it's "simply" a memory usage issue then maybe the only guarenteed fix is to throw more RAM at your server.
0
 
EyeContactAuthor Commented:
We didn't really solve the problem, but you took your time to help me so I accepted your answer. I emailed the asppainter guys and I hope to get a response from them soon.

EC.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now