Solved

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

Posted on 2000-03-07
6
281 Views
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.

John






0
Comment
Question by:john_jenkins
6 Comments
 
LVL 18

Expert Comment

by:mgfranz
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.
0
 
LVL 15

Expert Comment

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

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

Accepted Solution

by:
webmeister earned 200 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

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

Cheers,

Daryl

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

 

Expert Comment

by:Murdok
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...

murdok
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 2598013
0
 

Author Comment

by:john_jenkins
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)

John
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

15 Experts available now in Live!

Get 1:1 Help Now