session.abandon and clear cache

D

DC Gringo

I have an app that I can't seem to clear out server resources with a button
onclick event:

The session variables seem to be disappearing properly, but the
aspnet_wp.exe process stays where it had been upon running a heavy data
query. At a normal standstill it's at about 30-40MB and even after the code
below runs, it's up at 110MB.

What am I doing wrong?

Public Sub btnStartOver_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStartOver.Click

Session.Abandon()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(Now().AddSeconds(-1))
Response.Cache.SetNoStore()
Response.AddHeader("Pragma", "no-cache")

End Sub
 
J

jasonkester

You're not doing anything that would free up resources on the server.

Your first line tells the browser to clear cookies from you. The next
4 lines instruct the client to clear up resources on its end.

If you have Database resources left hanging around, you may want to
investigate and make sure you're closing your connections and otherwise
disposing of things correctly. Look into the 'using' syntax, if you
have not already.

Good luck!

Jason
Expat Software Consulting Services
http://www.expatsoftware.com/
 
D

DC Gringo

Jason,

Shouldn't session.abandon() clear it up?

It is the aspnet_wp.exe that is consuming the resources. I am fine with
what the database is doing...

______
DC G
 
J

jasonkester

ASP.NET strives to be essentially stateless, and you have to go out of
your way to make it behave otherwise. Unless you're explicitly storing
big things on the session (which you should not be doing), then
Session.Abandon() won't free much of anything on the server side.

My suspicion, that I voiced so poorly in my earlier response, is that
you have a resource leak somewhere. .NET is all about automatic
garbage collection, but it is still possible to leave resources like
database connections and file handles in an uncollectable state.
Something as simple as forgetting to call yourDBConnection.Close()
could leave that connection alive for quite a while after the page goes
out the door. This would manifest itself as an increase in memory
consumption in aspnet_wp.exe, the process that does all the work to
display your pages.

So again, I'd take a look at the code that does your database work.
Make sure that every disposable resource you use is declared with the
'using' syntax, and that everything closable gets .Close()'d before you
let it drop out of scope.

Hope this clears up some confusion!

Jason
Expat Software Consulting Services
http://www.expatsoftware.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top