473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

GC on a Session Variable

Hi,

I ve ended up debugging a ASP.NET project (with about 380 files on the
project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory
rises too fast. With about 25-30 active sessions (average) the memory rises
about 300 MB's in an hour. I've checked the database (SQL Server 2000) and
seen that there are lots of sleeping connections. (about 400!!!) I thought
somewhere in the code they left the connection open, so decided to log every
closing of the connection. I found out that connection is never closed...
The connection object is kept in session . (for each session at least 3
connection is opened and 1 connection is stored session) What I am
wondering is; could it be the connection object filling up the memory? Since
it is kept in the session and never disposed would it stop the GC from
collecting the other session variables? I ve found out that there are
Placeholders in the session too... could it be the case that the connection
is holding the placeholders from being collected.

Does asp.net open a new instance for each new session? If it is, when does
that instance killed? at session time out?

I cant close the connection cause the project is too big and online database
objects are used in almost each file. I did put a con.close() at Session on
end but it doesnt seem to be firing cause I am also logging to text file in
Session on end and it does nt seem to log anything.

Another interesting thing is that the machine has 2 GB physical memory but
when the memory reaches 0.8 - 1 GB I get the System.OutofMemoryException.
Why is that? why cant the Application use the free 1 GB?

Gonenc

Nov 18 '05 #1
6 2360
> The connection object is kept in session . (for each session at least 3
connection is opened and 1 connection is stored session) For a web app, this is a cardinal sin, which is one of the reasons why the
application is not scaling properly. Just opening a bare bones connection
takes 40kb of data on the average so do the math. Connections stored in
session have references, garbage collection cannot occur while this
reference exists therefor memory is leaked.

What's a sleeping connection?

Something else concerns me. Is connection pooling on? The pooling mechanism
works on exact connection string matches so for example if you were building
out your connection string or modifying it in anyway, connection pooling
would not work and connections would pile up in memory.
--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl... Hi,

I ve ended up debugging a ASP.NET project (with about 380 files on the
project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory rises too fast. With about 25-30 active sessions (average) the memory rises about 300 MB's in an hour. I've checked the database (SQL Server 2000) and
seen that there are lots of sleeping connections. (about 400!!!) I thought
somewhere in the code they left the connection open, so decided to log every closing of the connection. I found out that connection is never closed...
The connection object is kept in session . (for each session at least 3
connection is opened and 1 connection is stored session) What I am
wondering is; could it be the connection object filling up the memory? Since it is kept in the session and never disposed would it stop the GC from
collecting the other session variables? I ve found out that there are
Placeholders in the session too... could it be the case that the connection is holding the placeholders from being collected.

Does asp.net open a new instance for each new session? If it is, when does
that instance killed? at session time out?

I cant close the connection cause the project is too big and online database objects are used in almost each file. I did put a con.close() at Session on end but it doesnt seem to be firing cause I am also logging to text file in Session on end and it does nt seem to log anything.

Another interesting thing is that the machine has 2 GB physical memory but
when the memory reaches 0.8 - 1 GB I get the System.OutofMemoryException.
Why is that? why cant the Application use the free 1 GB?

Gonenc

Nov 18 '05 #2
I hit send by mistake, sorry i wasnt done yet.
I found out that connection is never closed... Connections are never closed when connection pooling is on. They are just
flagged as closed and sent to the pool to wait it out so if you opened and
closed 5 connections on the same connection string, you are really using the
same object from the pool. If you muck with the connection string or
connection pooling is off, you are using 5 different objects. The
application will fail to scale.
Does asp.net open a new instance for each new session? If it is, when does
that instance killed? at session time out? Session should be cleared at session end but by default that is 20 minutes.
If you have large objects in session, memory can quickly pile up. Also check
your datasets to see if you are nulling them out after using them. It's easy
to write a web application, its difficult to master the art of building a
well behaved web application.
--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl... Hi,

I ve ended up debugging a ASP.NET project (with about 380 files on the
project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory rises too fast. With about 25-30 active sessions (average) the memory rises about 300 MB's in an hour. I've checked the database (SQL Server 2000) and
seen that there are lots of sleeping connections. (about 400!!!) I thought
somewhere in the code they left the connection open, so decided to log every closing of the connection. I found out that connection is never closed...
The connection object is kept in session . (for each session at least 3
connection is opened and 1 connection is stored session) What I am
wondering is; could it be the connection object filling up the memory? Since it is kept in the session and never disposed would it stop the GC from
collecting the other session variables? I ve found out that there are
Placeholders in the session too... could it be the case that the connection is holding the placeholders from being collected.

Does asp.net open a new instance for each new session? If it is, when does
that instance killed? at session time out?

I cant close the connection cause the project is too big and online database objects are used in almost each file. I did put a con.close() at Session on end but it doesnt seem to be firing cause I am also logging to text file in Session on end and it does nt seem to log anything.

Another interesting thing is that the machine has 2 GB physical memory but
when the memory reaches 0.8 - 1 GB I get the System.OutofMemoryException.
Why is that? why cant the Application use the free 1 GB?

Gonenc

Nov 18 '05 #3
thanx for the quick reply Alvin... First of all I did not write the code...
I am just trying to keep it running, my company bought such a bad code from
a "software company"... I did not actually check if the connection pooling
is on... it must be on from default right? I did check the connection
string. All the connections are opened with the exact same connection
string. But since the connection is never actually closed I think it never
does make it back to the connection pool. What I meant by connection is
never closed is, there is no con.Close() statement!!! (I ve added to Session
on end at global.asax but i am not sure that it is firing in each session)

All the DB operations are done with datareaders, no datasets... I did try
null ing each datareader on the project after using it but it did not help
at all... Sleeping connections are the connections in SQL Server (I checked
it from SQL Server enterprise manager) with the sleeping status.. I saw a
connection opened 12 hours ago.. Either it is pooled and reused or it is
unreferenced and kept open? (but it will eventually timeout and 12 hours is
too much for a timeout? right? )
Connections stored in session have references, garbage collection cannot occur while this reference exists therefor memory is leaked.
Does the GC collect an object which contains an object which is referenced.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I end
up with a leak much more higher...

I still cant understand why out of memory exception is thrown while there is
1 GB physical memory available... Does IIS 5.0 and framework 1.0 have a bug
like this? Is there a limit on ASP.NET applications?
It's easy to write a web application, its difficult to master the art of building a well behaved web application.
tell me about it... I have being debugging this problem for 2 weeks... I
even thought of writing the whole project from scratch and found out that
the software is written from scratch by the seller company... (I will
install the new version, but I have to keep the old one up for a while... )
I think this is just a perfect example of what you have said...

Thanx

Gonenc

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl... I hit send by mistake, sorry i wasnt done yet.
I found out that connection is never closed... Connections are never closed when connection pooling is on. They are just
flagged as closed and sent to the pool to wait it out so if you opened and
closed 5 connections on the same connection string, you are really using

the same object from the pool. If you muck with the connection string or
connection pooling is off, you are using 5 different objects. The
application will fail to scale.
Does asp.net open a new instance for each new session? If it is, when does that instance killed? at session time out? Session should be cleared at session end but by default that is 20

minutes. If you have large objects in session, memory can quickly pile up. Also check your datasets to see if you are nulling them out after using them. It's easy to write a web application, its difficult to master the art of building a
well behaved web application.
--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
Hi,

I ve ended up debugging a ASP.NET project (with about 380 files on the
project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The

memory
rises too fast. With about 25-30 active sessions (average) the memory

rises
about 300 MB's in an hour. I've checked the database (SQL Server 2000) and seen that there are lots of sleeping connections. (about 400!!!) I thought somewhere in the code they left the connection open, so decided to log

every
closing of the connection. I found out that connection is never closed... The connection object is kept in session . (for each session at least 3
connection is opened and 1 connection is stored session) What I am
wondering is; could it be the connection object filling up the memory?

Since
it is kept in the session and never disposed would it stop the GC from
collecting the other session variables? I ve found out that there are
Placeholders in the session too... could it be the case that the

connection
is holding the placeholders from being collected.

Does asp.net open a new instance for each new session? If it is, when does that instance killed? at session time out?

I cant close the connection cause the project is too big and online

database
objects are used in almost each file. I did put a con.close() at Session

on
end but it doesnt seem to be firing cause I am also logging to text file

in
Session on end and it does nt seem to log anything.

Another interesting thing is that the machine has 2 GB physical memory but when the memory reaches 0.8 - 1 GB I get the System.OutofMemoryException. Why is that? why cant the Application use the free 1 GB?

Gonenc




Nov 18 '05 #4
> string. But since the connection is never actually closed I think it never
does make it back to the connection pool. There are very few instances when this is good. Connections, as rule, should
be closed immediately after they are used. It's not a good idea to wait
until session_end because, there are a few instances when session_end does
not get called. Is there a good reason for these connections to remain open?
If not, manually close the connection after it is used or put a using
declaration around the connection object like so.
using( oledbconnection db = new oledbconnection())
{
//use it here
}// it gets closed and disposed automatically here whether or not an
exception occurs.

Sleeping connections are not always the fault of the code. In my case,
sleeping connections were actually the fault of the informix engine and it
required a service pack to patch it up. You may want to make sure your
database engine is correctly plugged and patched first before touching your
code.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I end up with a leak much more higher... The session doesn't stay in memory but rather the object stored in session
remains. If this object is a dataset, you are leaking serious memory because
it will persist until the application domain unloads or the reference is
removed, whichever happens first.

You may want to check the size of your memory allocation on the server to
see what it is set to. In addition, you may want to aggressively lower the
memory recycle property of IIS. By default it will recycle the app after 60%
consumption. I've set mine to 40% because I don't want the appserver to
crawl to a halt when memory becomes an issue. Also, the task manager does
not correctly report memory consumption. It's just a ruff estimate. You need
a more potent tool like memory profiler available from microsoft. In
addition to that, you need to start doing some sort of instrumentation on
the webserver - monitoring memory consumption using perfmon logs to get a
clearer picture of just what is going on. That's all I can think of for the
moment. I've had similar leaky apps, and it boils down to plain old elbow
grease to solve it.

--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl... thanx for the quick reply Alvin... First of all I did not write the code... I am just trying to keep it running, my company bought such a bad code from a "software company"... I did not actually check if the connection pooling
is on... it must be on from default right? I did check the connection
string. All the connections are opened with the exact same connection
string. But since the connection is never actually closed I think it never
does make it back to the connection pool. What I meant by connection is
never closed is, there is no con.Close() statement!!! (I ve added to Session on end at global.asax but i am not sure that it is firing in each session)

All the DB operations are done with datareaders, no datasets... I did try
null ing each datareader on the project after using it but it did not help
at all... Sleeping connections are the connections in SQL Server (I checked it from SQL Server enterprise manager) with the sleeping status.. I saw a
connection opened 12 hours ago.. Either it is pooled and reused or it is
unreferenced and kept open? (but it will eventually timeout and 12 hours is too much for a timeout? right? )
Connections stored in session have references, garbage collection cannot occur while this
reference exists therefor memory is leaked.


Does the GC collect an object which contains an object which is

referenced. So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I end up with a leak much more higher...

I still cant understand why out of memory exception is thrown while there is 1 GB physical memory available... Does IIS 5.0 and framework 1.0 have a bug like this? Is there a limit on ASP.NET applications?
It's easy to write a web application, its difficult to master the art of building a
well behaved web application.


tell me about it... I have being debugging this problem for 2 weeks... I
even thought of writing the whole project from scratch and found out that
the software is written from scratch by the seller company... (I will
install the new version, but I have to keep the old one up for a

while... ) I think this is just a perfect example of what you have said...

Thanx

Gonenc

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
I hit send by mistake, sorry i wasnt done yet.
I found out that connection is never closed...

Connections are never closed when connection pooling is on. They are just
flagged as closed and sent to the pool to wait it out so if you opened and closed 5 connections on the same connection string, you are really using

the
same object from the pool. If you muck with the connection string or
connection pooling is off, you are using 5 different objects. The
application will fail to scale.
Does asp.net open a new instance for each new session? If it is, when does that instance killed? at session time out?

Session should be cleared at session end but by default that is 20

minutes.
If you have large objects in session, memory can quickly pile up. Also

check
your datasets to see if you are nulling them out after using them. It's

easy
to write a web application, its difficult to master the art of building a well behaved web application.
--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
Hi,

I ve ended up debugging a ASP.NET project (with about 380 files on the
project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The

memory
rises too fast. With about 25-30 active sessions (average) the memory

rises
about 300 MB's in an hour. I've checked the database (SQL Server 2000) and seen that there are lots of sleeping connections. (about 400!!!) I thought somewhere in the code they left the connection open, so decided to log

every
closing of the connection. I found out that connection is never closed... The connection object is kept in session . (for each session at least 3 connection is opened and 1 connection is stored session) What I am
wondering is; could it be the connection object filling up the memory?

Since
it is kept in the session and never disposed would it stop the GC from
collecting the other session variables? I ve found out that there are
Placeholders in the session too... could it be the case that the

connection
is holding the placeholders from being collected.

Does asp.net open a new instance for each new session? If it is, when does that instance killed? at session time out?

I cant close the connection cause the project is too big and online

database
objects are used in almost each file. I did put a con.close() at
Session on
end but it doesnt seem to be firing cause I am also logging to text
file in
Session on end and it does nt seem to log anything.

Another interesting thing is that the machine has 2 GB physical memory

but when the memory reaches 0.8 - 1 GB I get the System.OutofMemoryException. Why is that? why cant the Application use the free 1 GB?

Gonenc



Nov 18 '05 #5
I have to second Alvin on this, keeping connection references in Session is
a horrid idea and whoever designed it obviously didnt understand anything
about ASP.Net

That point said, you're gonna need to do some rewriting, in the sense of
explicitly opening and closing connections when used.
--
Eric Newton
er**@ensoft-software.com.cc (Remove the CC)
www.ensoft-software.com
C#/ASP.net Solutions developer

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
string. But since the connection is never actually closed I think it never
does make it back to the connection pool. There are very few instances when this is good. Connections, as rule,

should be closed immediately after they are used. It's not a good idea to wait
until session_end because, there are a few instances when session_end does
not get called. Is there a good reason for these connections to remain open? If not, manually close the connection after it is used or put a using
declaration around the connection object like so.
using( oledbconnection db = new oledbconnection())
{
//use it here
}// it gets closed and disposed automatically here whether or not an
exception occurs.

Sleeping connections are not always the fault of the code. In my case,
sleeping connections were actually the fault of the informix engine and it
required a service pack to patch it up. You may want to make sure your
database engine is correctly plugged and patched first before touching your code.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I end
up with a leak much more higher...

The session doesn't stay in memory but rather the object stored in session
remains. If this object is a dataset, you are leaking serious memory

because it will persist until the application domain unloads or the reference is
removed, whichever happens first.

You may want to check the size of your memory allocation on the server to
see what it is set to. In addition, you may want to aggressively lower the
memory recycle property of IIS. By default it will recycle the app after 60% consumption. I've set mine to 40% because I don't want the appserver to
crawl to a halt when memory becomes an issue. Also, the task manager does
not correctly report memory consumption. It's just a ruff estimate. You need a more potent tool like memory profiler available from microsoft. In
addition to that, you need to start doing some sort of instrumentation on
the webserver - monitoring memory consumption using perfmon logs to get a
clearer picture of just what is going on. That's all I can think of for the moment. I've had similar leaky apps, and it boils down to plain old elbow
grease to solve it.

--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
thanx for the quick reply Alvin... First of all I did not write the code...
I am just trying to keep it running, my company bought such a bad code

from
a "software company"... I did not actually check if the connection pooling is on... it must be on from default right? I did check the connection
string. All the connections are opened with the exact same connection
string. But since the connection is never actually closed I think it never does make it back to the connection pool. What I meant by connection is
never closed is, there is no con.Close() statement!!! (I ve added to

Session
on end at global.asax but i am not sure that it is firing in each session)
All the DB operations are done with datareaders, no datasets... I did try null ing each datareader on the project after using it but it did not help at all... Sleeping connections are the connections in SQL Server (I

checked
it from SQL Server enterprise manager) with the sleeping status.. I saw a connection opened 12 hours ago.. Either it is pooled and reused or it is
unreferenced and kept open? (but it will eventually timeout and 12 hours

is
too much for a timeout? right? )
Connections stored in session have references, garbage collection cannot
occur while this
reference exists therefor memory is leaked.


Does the GC collect an object which contains an object which is

referenced.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I

end
up with a leak much more higher...

I still cant understand why out of memory exception is thrown while there is
1 GB physical memory available... Does IIS 5.0 and framework 1.0 have a bug
like this? Is there a limit on ASP.NET applications?
It's easy to write a web application, its difficult to master the art

of building a
well behaved web application.


tell me about it... I have being debugging this problem for 2 weeks... I
even thought of writing the whole project from scratch and found out that the software is written from scratch by the seller company... (I will
install the new version, but I have to keep the old one up for a

while... )
I think this is just a perfect example of what you have said...

Thanx

Gonenc

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
I hit send by mistake, sorry i wasnt done yet.

>I found out that connection is never closed...
Connections are never closed when connection pooling is on. They are just flagged as closed and sent to the pool to wait it out so if you opened and closed 5 connections on the same connection string, you are really
using the
same object from the pool. If you muck with the connection string or
connection pooling is off, you are using 5 different objects. The
application will fail to scale.

> Does asp.net open a new instance for each new session? If it is,
when does
> that instance killed? at session time out?
Session should be cleared at session end but by default that is 20

minutes.
If you have large objects in session, memory can quickly pile up. Also

check
your datasets to see if you are nulling them out after using them.
It's easy
to write a web application, its difficult to master the art of
building a well behaved web application.
--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I ve ended up debugging a ASP.NET project (with about 380 files on
the > project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The memory
> rises too fast. With about 25-30 active sessions (average) the memory rises
> about 300 MB's in an hour. I've checked the database (SQL Server 2000) and
> seen that there are lots of sleeping connections. (about 400!!!) I thought
> somewhere in the code they left the connection open, so decided to
log every
> closing of the connection. I found out that connection is never

closed...
> The connection object is kept in session . (for each session at least 3 > connection is opened and 1 connection is stored session) What I am
> wondering is; could it be the connection object filling up the
memory? Since
> it is kept in the session and never disposed would it stop the GC from > collecting the other session variables? I ve found out that there are > Placeholders in the session too... could it be the case that the
connection
> is holding the placeholders from being collected.
>
> Does asp.net open a new instance for each new session? If it is,

when does
> that instance killed? at session time out?
>
> I cant close the connection cause the project is too big and online
database
> objects are used in almost each file. I did put a con.close() at Session on
> end but it doesnt seem to be firing cause I am also logging to text file in
> Session on end and it does nt seem to log anything.
>
> Another interesting thing is that the machine has 2 GB physical

memory but
> when the memory reaches 0.8 - 1 GB I get the

System.OutofMemoryException.
> Why is that? why cant the Application use the free 1 GB?
>
> Gonenc
>
>
>



Nov 18 '05 #6
I figure the technology is new and not every programmer knows best
practices. Learning takes a while, in that while, the software suffers and
so does the client. Which is why customers don't think highly of developers
either.

--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Eric Newton" <er**********@hotmail.com> wrote in message
news:Od**************@TK2MSFTNGP11.phx.gbl...
I have to second Alvin on this, keeping connection references in Session is a horrid idea and whoever designed it obviously didnt understand anything
about ASP.Net

That point said, you're gonna need to do some rewriting, in the sense of
explicitly opening and closing connections when used.
--
Eric Newton
er**@ensoft-software.com.cc (Remove the CC)
www.ensoft-software.com
C#/ASP.net Solutions developer

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
string. But since the connection is never actually closed I think it never does make it back to the connection pool. There are very few instances when this is good. Connections, as rule,

should
be closed immediately after they are used. It's not a good idea to wait
until session_end because, there are a few instances when session_end does
not get called. Is there a good reason for these connections to remain

open?
If not, manually close the connection after it is used or put a using
declaration around the connection object like so.
using( oledbconnection db = new oledbconnection())
{
//use it here
}// it gets closed and disposed automatically here whether or not an
exception occurs.

Sleeping connections are not always the fault of the code. In my case,
sleeping connections were actually the fault of the informix engine and it required a service pack to patch it up. You may want to make sure your
database engine is correctly plugged and patched first before touching

your
code.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection I
end
up with a leak much more higher...

The session doesn't stay in memory but rather the object stored in session remains. If this object is a dataset, you are leaking serious memory

because
it will persist until the application domain unloads or the reference is
removed, whichever happens first.

You may want to check the size of your memory allocation on the server to see what it is set to. In addition, you may want to aggressively lower the memory recycle property of IIS. By default it will recycle the app after

60%
consumption. I've set mine to 40% because I don't want the appserver to
crawl to a halt when memory becomes an issue. Also, the task manager does not correctly report memory consumption. It's just a ruff estimate. You

need
a more potent tool like memory profiler available from microsoft. In
addition to that, you need to start doing some sort of instrumentation on the webserver - monitoring memory consumption using perfmon logs to get a clearer picture of just what is going on. That's all I can think of for

the
moment. I've had similar leaky apps, and it boils down to plain old elbow grease to solve it.

--
Regards,
Alvin Bruney
http://www.networkip.net/dotnet/tidbits/default.htm
"Gonenc Ercan" <go*****@superonline.com> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
thanx for the quick reply Alvin... First of all I did not write the

code...
I am just trying to keep it running, my company bought such a bad code

from
a "software company"... I did not actually check if the connection pooling is on... it must be on from default right? I did check the connection
string. All the connections are opened with the exact same connection
string. But since the connection is never actually closed I think it never does make it back to the connection pool. What I meant by connection
is never closed is, there is no con.Close() statement!!! (I ve added to

Session
on end at global.asax but i am not sure that it is firing in each

session)
All the DB operations are done with datareaders, no datasets... I did try null ing each datareader on the project after using it but it did not help at all... Sleeping connections are the connections in SQL Server (I

checked
it from SQL Server enterprise manager) with the sleeping status.. I saw a
connection opened 12 hours ago.. Either it is pooled and reused or it
is unreferenced and kept open? (but it will eventually timeout and 12 hours is
too much for a timeout? right? )

> Connections stored in session have references, garbage collection cannot occur while this
> reference exists therefor memory is leaked.

Does the GC collect an object which contains an object which is referenced.
So in this case; Session contains a connection which is referenced, so
session stays in the memory to? So instead of 40 KB of the connection
I end
up with a leak much more higher...

I still cant understand why out of memory exception is thrown while there
is
1 GB physical memory available... Does IIS 5.0 and framework 1.0 have

a bug
like this? Is there a limit on ASP.NET applications?

> It's easy to write a web application, its difficult to master the
art of building a
> well behaved web application.

tell me about it... I have being debugging this problem for 2 weeks...
I even thought of writing the whole project from scratch and found out

that the software is written from scratch by the seller company... (I will
install the new version, but I have to keep the old one up for a

while... )
I think this is just a perfect example of what you have said...

Thanx

Gonenc

"Alvin Bruney" <vapor at steaming post office> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
> I hit send by mistake, sorry i wasnt done yet.
>
> >I found out that connection is never closed...
> Connections are never closed when connection pooling is on. They are

just
> flagged as closed and sent to the pool to wait it out so if you opened and
> closed 5 connections on the same connection string, you are really using the
> same object from the pool. If you muck with the connection string or
> connection pooling is off, you are using 5 different objects. The
> application will fail to scale.
>
> > Does asp.net open a new instance for each new session? If it is, when does
> > that instance killed? at session time out?
> Session should be cleared at session end but by default that is 20
minutes.
> If you have large objects in session, memory can quickly pile up.
Also check
> your datasets to see if you are nulling them out after using them. It's easy
> to write a web application, its difficult to master the art of building
a
> well behaved web application.
> --
> Regards,
> Alvin Bruney
> http://www.networkip.net/dotnet/tidbits/default.htm
> "Gonenc Ercan" <go*****@superonline.com> wrote in message
> news:e9**************@TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > I ve ended up debugging a ASP.NET project (with about 380 files on

the > > project .NET Framework 1.0 on IIS 5.0) which has a memory leak... The > memory
> > rises too fast. With about 25-30 active sessions (average) the memory > rises
> > about 300 MB's in an hour. I've checked the database (SQL Server 2000) and
> > seen that there are lots of sleeping connections. (about 400!!!) I
thought
> > somewhere in the code they left the connection open, so decided to log > every
> > closing of the connection. I found out that connection is never
closed...
> > The connection object is kept in session . (for each session at least
3
> > connection is opened and 1 connection is stored session) What I am > > wondering is; could it be the connection object filling up the

memory? > Since
> > it is kept in the session and never disposed would it stop the GC from > > collecting the other session variables? I ve found out that there are > > Placeholders in the session too... could it be the case that the
> connection
> > is holding the placeholders from being collected.
> >
> > Does asp.net open a new instance for each new session? If it is, when does
> > that instance killed? at session time out?
> >
> > I cant close the connection cause the project is too big and online > database
> > objects are used in almost each file. I did put a con.close() at

Session
> on
> > end but it doesnt seem to be firing cause I am also logging to
text file
> in
> > Session on end and it does nt seem to log anything.
> >
> > Another interesting thing is that the machine has 2 GB physical

memory but
> > when the memory reaches 0.8 - 1 GB I get the
System.OutofMemoryException.
> > Why is that? why cant the Application use the free 1 GB?
> >
> > Gonenc
> >
> >
> >
>
>



Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
1
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
2
by: Eric | last post by:
Hi, I've a problem with trying to retrieve a session variable in an include file. Basically, the main asp creates a session variable: <% Session("var1") = "Hello" %> And then when I click...
4
by: VB Programmer | last post by:
If I have a variable I want to share in my application what is the difference between just declaring a variable (Dim strMyVar as String) and using a session variable (Session("strMyVar"))? When...
9
by: William LaMartin | last post by:
I have a problem, mentioned here before, of Session and Application variables disappearing at one site but not at others or on my development computer. The problem is illustrated by an example...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
4
by: T Ralya | last post by:
I am told that ASP.NET controls the session ID and session variables, but that does not fit my symptoms. I am posting here as directed. I'm hoping that someone can at least recommend something to...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
4
by: Don Miller | last post by:
I am using a Session variable to hold a class object between ASP.NET pages (in VB). In my constructor I check to see if the Session variable exists, and if it doesn't, I create one and populate it...
17
by: Control Freq | last post by:
Hi, Not sure if this is the right NG for this, but, is there a convention for the variable names of a Session variable? I am using .NET 2.0 in C#. I am new to all this .NET stuff, So, any...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.