Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


ASP & IIS - memory just drains away....

Posted on 2000-03-07
Medium Priority
Last Modified: 2010-08-05
I have a busy site running IIS4 & using ASP/ADO (quite a bit....).

Over a period of time (4-6 hours) the memory just leaks away - I have reduced my usage of Session variables to an absolute minimum and the site runs faster - but the memory seems to leak away even faster.

It looks as if IIS doesn't garbage collect it's ASP space quickly enough, and the load on memory just builds up more quickly than it is being cleared out (see below - if left alone it DOES eventually clear out).

Running in separate memory space just seems to make it worse.

Response times are OK (20 threads) until memory gets in short supply, then it falls apart quickly.

I have run the site in isolation with test sessions only, and if I let the site go quiescent, the memory comes back after about 50 minutes (20 minutes session timeout + 30 minutes) - this is quite consistent.

If I just drive the site at 'live' speed then I get the same problem. Extra memory on the web server just delays the inevitable.

The question is : How do I fix this...

Is it:
1. Using session variables AT ALL?
2. A tuning issue for IIS (e.g. forcing garbage collect)?
3. More webservers to spread the load?
4. Getting the server to detect the situation and auto-reboot (how?)
5. Something else........

Any advice much appreciated.


Question by:john_jenkins
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Expert Comment

ID: 2592615
What version of VBScript engine are you running?  there was a memeory leak problem associated with Month(date) in IIS 4.0.  First ensure your engine is 3.1 or above.  Run the following code;

<%@ language=VBScript%>

'**Start Encode**
Function GetScriptEngineInfo()
 Dim s
 s = ""                        ' Build string with necessary info.
 s = ScriptEngine & " Version "
 s = s & ScriptEngineMajorVersion & "."
 s = s & ScriptEngineMinorVersion & "."
 s = s & ScriptEngineBuildVersion
 GetScriptEngineInfo = s      ' Return the results.
End Function

<%= GetScriptEngineInfo %>

Try running Heap Watch, HW32 lets you view application heaps and monitor them for memory leaks. The Summary-view window shows a list of the heaps for all active Win32-based applications. The Details-view window shows all memory objects in the selected heap. The Object-view window shows the blocks of memory that were allocated for the given object.

Also, make sure you are closing all your ADO/ODBC connections.
LVL 15

Expert Comment

ID: 2592679
Every time you
Set obj = CreateObject...
you have to
Set obj = Nothing

In our company, one coded;
Set obj = CreateObject...
in a loop, but nulled it only once, after the loop.
(That was a few MB for each loop...)

Also, we used a C COM object which caused drastic memory leakage.

Accepted Solution

webmeister earned 600 total points
ID: 2592734
Hi John there are a couple of quicks checks you can make:

1)Many high traffic sites use session variables with very few problems.  However there are a couple of issues.  Make sure that you are not storing references to objects in the session. Eg don't do a createObject and them store that in a session.  That will tie that specific ojbect to that session and retain it in memory until the session gets dumped.  Very bad.  Instead store the object in an application variable.  You can so this through ASP on the page or through an <object> tag in your global.asa

<object ID=Name SCOPE=Application Runat=Server Name="object.class"></object>

2) IIS 4.0 is a little better with garbage collection than 3.0 was.  You still should make sure that you set any object reference to nothing at the bottom of your page.  Eg if you use ser ver.createobject to create a database connection make sure you .close() it and set it to nothing
set objName = nothing

3) If you specified your hardware situation and load I could better tell you wif the machine is just being overloaded.  I doubt it though.  And if you have one bad application it doesnt matter how many servers you throw at it

4)  I wouldnt set the server to reboot a lot of sysadmins do this and claim that NT just requires a reboot every so often.  I disagree.  A lot of big companies use IIS in heavy loads and don't have to reboot the server once a day.  They'll tell you how Linux will run forever without a reboot.  I just think that the sysadmins arent looking hard enough and maybe dont know all the settings that an enterprise level web server requires.  The best thing you can do for yourself once you get this ironed out is get a copy of the IIS resource kit.  Hopefully MS will release one for WIn 2000/IIS 5.0



Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Expert Comment

ID: 2596649
First you must do is avoid the sentences like Set obj = CreateObject("dsdfsdfd.blabla") because it create the object although there is not to use, you must use the HTML tag <OBJECT RUNAT=Server ...> because it not create the object until one method is called.

Second, you must looking for your load balancing software, perhaps a good idea was to use MTS to register your components

Third, you must avoid de Session_OnStar and Session_OnEnd methods if in your global.asa are empty these ones you must delete.

Fourth, you must work without isolated process, because it is only to debug...

A best solution is work with Windows 2000 server and use IIS 5.0 because it works fine and you can decide whats happend when your IIS crash...

LVL 18

Expert Comment

ID: 2598013

Author Comment

ID: 2607449
Thanks to all (particularly webmeister) all good stuff. The good news is that we've cracked the problem (Hoorah).

There WAS some minor leakage with COM objects in session variables (fixed now), however the real problem was in Microsoft's ADODB interface which has a big memory hole in it.

We found that using a .close method and then setting the variable to Nothing did not release memory. We tried various methods of Destroy-ing the object and eventually resorted to doing an explicit destruction of the object in our own .DLL - everything is now sweet and the site FLIES.......

Thanks again (living & learning)


Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

721 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