Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

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

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
john_jenkins
Asked:
john_jenkins
1 Solution
 
mgfranzCommented:
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
 
robbertCommented:
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
 
webmeisterCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MurdokCommented:
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
 
mgfranzCommented:
0
 
john_jenkinsAuthor Commented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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