Improve company productivity with a Business Account.Sign Up


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



Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Watch the software video of Kernel Import PST to Office 365 tools which can easily import PST and OST files to Office 365 for bulk mailboxes. The process of migration is simple and user can map source and destination mailboxes and easily import data…

585 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