Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to release object stored in property?
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01397173
Message ID:
01397447
Views:
38
>
>I use ANT profiler to trace the memory, and I found that some objects is not released (new object created) after every postback.
>
>1. MyBO.SomeEvent
>2. Button
>3. MyDataGridView
>
>Question: How could I free up them upon every postback? In which event/method should I place code to nullify the child object?
>

Try unhooking the event handler from your business object in the Page_Unload(). It's probably keeping the business object from being cleaned up by the GC. You can also set your property to null here if you want (although it shouldn't be necessary).
protected void Page_unLoaded(object sender, EventArgs e)
{ 
   this._myBO.SomeEvent -= this.MyBO_SomeEvent;

}
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform