Click to See Complete Forum and Search --> : serious memory leak...


minion
09-29-2003, 12:02 AM
ok.. here is the breakdown of how the code is set up..

every page has a at the very top,..

in inc_common.asp are a set of subs and functions that are called by the pages in the site to perform certain tasks (display content, lookup info in DB, etc)

inc_common.asp makes one DB connection object, which is used by all the subs and functions in it.



this sytem makes heavy use of the DB connection (MySQL) as every part of the site is Dynamic almost ..

when there is high traffic on the site, there is a steady leak in memory .. it goes FAST .. problems start to happen within a few hrs , or sometimes even 30 min if the traffic is high enough.. the site slows down drastically due to the memory starvation, and then eventually IIS dies..


WHAT I HAVE ALREADY TRIED:

- Wrote custom DLL to handle database access
- resulted in a MASSIVE increase in the mem. leak..
- made each sub / function open and close the db connection
- resulted in no change
- closed the DB connection and set to null wherever it needs to be (before redirects, at the end of the pages, etc.)
- resulted in no change..
- Wrote custom dll to handle string replace functions
- resulted in minor emprovement


this problem has been driving me nuts.. if someone can help me out here, it would be great!..

specs:
DB : MySQL
OS: windows2000
IIS: 5
lang: ASP


-Thank you

rdoekes
09-29-2003, 06:07 AM
Memory leaks is a pretty general statement. I guess somehow your code keeps objects or other stuff in memory, but not knowing your code it will be difficult to determine what the problem is.

Maybe the following list could help you a little bit:
1. Do you use session variables. If so, do you place objects in these session vars? This could consume a lot of resources.
2. how do you connect to the database? DSN (or -less), OLEDB or else? The fastest connection to a db is DSN-less, since you do not carry the DSN overhead.
3. Do you operations require many recordsets to be open at the same time? For instance: open recordset, loop, each record requires another recordset to be open, loop 2 etc...
If this is the case, you could opt to use arrays with RecordSet.GetRows(). Ensure you Erase these arrays when done.

Hope this helps,

-Rogier Doekes

minion
09-29-2003, 06:02 PM
thanks for ur reply rdoekes,

-i do use session variables, but with no objects.. just strings

- i connect to the db using a system dsn, ADODB

- operations require at most 3 recordsets to be open at any one time..


so it's none of those .. i'm actually starting to think that the problem isn't even in the DB, i think it may be in my include statements (which i just realised got taken out of the post .lol) .. basically i include inc_common.asp in every page, and inc_common is a pritty big file .. i have a feeling asp dosn't manage those include files very nicely ... if anyone knows anything about this , it would be great .. :-) . in the meantime i'm testing out my theory, i will post back here if this solves the problem ..

Ribeyed
09-29-2003, 06:21 PM
Hi,
been following this post. Don't have much to add apart from i also noticed a reduction in speed of the page when using include files. Here's a bit of code that will time your ASP page. I would time it with the include file then copy and paste the contents of the include file into your page and run without include file see what results you get.


<%
'get timer before task begins:

starttime = timer()
'do some task e.g.:

do while z < 350000
z = z + 1
loop

'get timer after task completes:
endtime = timer()

'display results:
response.write "The task completed in " & endtime-starttime & " s"
response.write " (" & (endtime-starttime)*1000 & " milliseconds)."

%>


Hope this helps

rdoekes
09-30-2003, 03:51 AM
I guess the include file might be the problem. Before any other statements are executed, ASP loads the entire contents of the includes in memory so it can be used when needed. If the file is big, this means a lot of code is loaded.

I advise you to look at your include file, divide it up in smaller include files and only use those includes you really need.

Hope this helps,

-Rogier Doekes

minion
09-30-2003, 11:40 PM
ok .. i've broken down the include file, it is now MUCH smaller, unfortunately this had no impact on the memory leak .. :-(

i'm starting to get really frustrated .. as far as i can tell , i close absolutely every object i set.

i have a footer file that i include at the bottom of every page.. this file masically closes any variables that may have been opened in the inc_common file .. so the general structure of the pages is as follows

------------------------------------
inc_common:

create and open DB connection
create and populate dictionary object

sub foo
do some stuff using the DB connection
close any recordset objects created
end sub

sub other_foo
do some other stuff with the DB
use dictionary object
close any recordset objects created
end sub



main page:
include 'inc_common'

call the functions in inc_coomon (<%foo%>)

do other html stuff
include 'footer'



footer:

close the db connection
set db object to nothing
set dictionary object to nothing

-----------------

now, unless asp does something weird with it's includes, and the included footer file dosn't actually close the db/dictionary objects, this should generate no mem. leaks .. am i missing something here?

Ribeyed
10-01-2003, 03:01 AM
Hi,
here is a couple of articals you should read regarding your problem.

http://www.aspfaq.com/show.asp?id=2227

and

http://support.microsoft.com/?scid=kb;en-us;q253706

minion
10-01-2003, 10:58 PM
Ribeyed,

i checked out the sites, upgraded the Data Access Components, and well .. so far , this seems to have at the very least significantly reduced the leak !! .. i won't know for sure exactly how stable the server is 'till i've been monitoring it for a while .. but so far (the last hr) , it's looking pritty good !!!!!

thank you so much !! .. this is my first post here, and i gotta tell u, i'm pritty happy with the feedback .. i think i may hang arround and help out where i can .. :-)

Ribeyed
10-02-2003, 02:50 AM
good stuff glad to hear you almost fixed your problem and that your sticking around ;)