Solved

How to clean up page variables when user closes the web page?

Posted on 2015-01-07
4
128 Views
Last Modified: 2015-01-08
Hi, I'm using vs2012.
I have several variables declared under the page class, public partial class _Default : Page

What's the best way to dispose() or clean up these variables?  I tried accessing them from Global.asax.cs in the Applicaiton-End event but I wasn't able to access these variables when I type in namesapce._Default.  None of the variables show up.
How to clean these up?
Thank you.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40536925
If they are declared inside the page object then they should go out of scope and be destroyed when the page unloads but if you want to handle this yourself then use the Page.Unload event
http://msdn.microsoft.com/en-us/library/system.web.ui.control.unload(v=vs.110).aspx
0
 

Author Comment

by:lapucca
ID: 40538556
These are variables/properties declare in the page object right after this loc
 public partial class _Default : Page

I have generic collection, about 20-100 objects. So would you recommend to let it go out of scope and garbage collector does its thing or calling the page.unload event to clean up? Thank you.
0
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 500 total points
ID: 40538633
.Net has pretty good GC algorithms and so unless it is unmanaged eg COM then I would the GC to the system and set the scope appropiately
0
 

Author Comment

by:lapucca
ID: 40538680
Sounds good.  Thank you.
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question