473,686 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OutofMem oryException.
Why is that? why cant the Application use the free 1 GB?

Gonenc

Nov 18 '05 #1
6 2382
> 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*****@supero nline.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException.
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*****@supero nline.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException.
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******** ******@TK2MSFTN GP10.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*****@supero nline.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException. 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*****@supero nline.com> wrote in message
news:e1******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP10.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*****@supero nline.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException. 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******** ********@TK2MSF TNGP11.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*****@supero nline.com> wrote in message
news:e1******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP10.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*****@supero nline.com> wrote in message
news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException.
> 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**********@h otmail.com> wrote in message
news:Od******** ******@TK2MSFTN GP11.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******** ********@TK2MSF TNGP11.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*****@supero nline.com> wrote in message
news:e1******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP10.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*****@supero nline.com> wrote in message
> news:e9******** ******@TK2MSFTN GP09.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.OutofMem oryException.
> > 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
3344
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 Explicit and Response.Expires=-1,
1
3107
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 "security update" installed on the server a few days ago but I can't find out exactly what it was. In the research I have done I found many articles on the subject of session variables in ASP pages inside framesets. From what I read a new...
2
13552
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 on a button it refers to the include file, which I believe is all client-side code as there are no server <% %> tags.
4
1650
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 should I use a session variable and when should I just declare it like normal? Thanks in advance!
9
2450
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 at http://www.lamartin.com/dotnet/sessiontestset.aspx, were I set Session, Application and Cache variables on the first page and then on the second page view them as the second page is refreshed every five seconds. Before 10 refreshes, the...
9
2382
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 - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone explaining what I'm doing wrong here & perhaps suggest a better approach.. I'm familiar with use of...
4
1948
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 try to isolate the problem. I have a simple application that demonstrates my problem. Page 1, step1: SaveSessionVariableButton will create a string value, show it on screen, save it in a session variable and show the session ID on screen....
3
2908
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 any experience on how to keep track of session value. Any help it's appreciated. Thanks Alan
4
3437
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 with "Me". But if the Session variable already exists, I would like the new object be populated with everything from the object stored in the Session variable. Ideally, I'd like to retrieve the object from the Session variable and assign it to...
17
5088
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 guidance appreciated. Regards
0
8586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8936
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7603
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5800
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.