NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 36 37 38 39 40 … 93 Next »
Memory management - controls and popups

 
  • 0 Vote(s) - 0 Average
Memory management - controls and popups
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#1
2008-01-06, 01:32 AM
Sub-

Couple questions about memory management:

1) What is the difference between skinHelper2.DisposeResources()
and PluginHelperFactory.getPluginHelper().DisposeResources(disposeList) ?

Should both be called in the Dispose method of each control instance?

2) Should the control's Dispose() call element.image.Dispose(), or does the call to the PluginHelper.DisposeResources do that under the covers. (see example below)

3) It looks like the UiButton.Dispose() method is empty. Shouldn't it call the PluginHelper dispose with the normal and selected UIElements?

Currently all the WizControls call the xxx.image.Dispose() method for each GBPVRUiElement object in the control as well as calling the PluginHelper dispose method at the end of the controls Dispose() routine.

For example, here is the dispose method for the text box:
Code:
[COLOR=black][SIZE=2]public [/SIZE][SIZE=2]override [/SIZE][SIZE=2]void[/SIZE][SIZE=2] Dispose()[/SIZE][/COLOR]
[SIZE=2][COLOR=black]{[/COLOR][/SIZE]
[SIZE=2][COLOR=black]  WizInfo.LogMessage("WizUiTextBox", "Dispose()", "Called for " + this.PlacementName);[/COLOR][/SIZE]
[COLOR=black][SIZE=2]  mRenderingRequired = [/SIZE][SIZE=2]false[/SIZE][SIZE=2];[/SIZE][/COLOR]
[COLOR=black][SIZE=2]  ArrayList[/SIZE][SIZE=2] disposeList = [/SIZE][SIZE=2]new[/SIZE][SIZE=2]ArrayList[/SIZE][SIZE=2]();[/SIZE][/COLOR]
[COLOR=black][SIZE=2]  if[/SIZE][SIZE=2] ([/SIZE][SIZE=2]this[/SIZE][SIZE=2].normalUiElement != [/SIZE][SIZE=2]null[/SIZE][SIZE=2])[/SIZE][/COLOR]
[COLOR=black][SIZE=2]      this[/SIZE][SIZE=2].normalUiElement.image.Dispose();[/SIZE][SIZE=2] disposeList.Add([/SIZE][SIZE=2]this[/SIZE][SIZE=2].normalUiElement);[/SIZE][/COLOR]

[COLOR=black][SIZE=2]   if[/SIZE][SIZE=2] ([/SIZE][SIZE=2]this[/SIZE][SIZE=2].selectedUiElement != [/SIZE][SIZE=2]null[/SIZE][SIZE=2])[/SIZE][/COLOR]
[SIZE=2][COLOR=black]   {[/COLOR][/SIZE]
[COLOR=black][SIZE=2]       this[/SIZE][SIZE=2].selectedUiElement.image.Dispose();[/SIZE][/COLOR]
[COLOR=black][SIZE=2]       disposeList.Add([/SIZE][SIZE=2]this[/SIZE][SIZE=2].selectedUiElement);[/SIZE][/COLOR]
[SIZE=2][COLOR=black]   }[/COLOR][/SIZE]
[COLOR=black][SIZE=2]   PluginHelperFactory[/SIZE][SIZE=2].getPluginHelper().DisposeResources(disposeList);[/SIZE][/COLOR]
[COLOR=black][SIZE=2]   normalUiElement = [/SIZE][SIZE=2]null[/SIZE][SIZE=2];[/SIZE][/COLOR]
[COLOR=black][SIZE=2]   selectedUiElement = [/SIZE][SIZE=2]null[/SIZE][SIZE=2];[/SIZE][/COLOR]
[SIZE=2][COLOR=black]}[/COLOR][/SIZE]
Is that the proper way to dispose of the objects?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,677
Threads: 767
Joined: Nov 2003
#2
2008-01-06, 02:30 AM
Sorry, I saw your other post the other day but it was late in the day and I was lacking the energy to respond Big Grin

JavaWiz Wrote:Sub-

Couple questions about memory management:

1) What is the difference between skinHelper2.DisposeResources()
and PluginHelperFactory.getPluginHelper().DisposeResources(disposeList) ?
You call PluginHelperFactory[SIZE=2].getPluginHelper().DisposeResources(disposeList) passing a list of any GBPVRUiElements you've manually created. These GBPVRUiElements have video texture memory associated with them, so making this call gives the framework a chance to free up that texture memory.[/SIZE]

skinHelper2.DisposeResources() tells the skinHelper to release extra resource it has cached. It doesnt hold any GBPVRUiElements objects, but it does have a cache of GDI resources like bitmaps/colours/fonts/brushes etc. Calling DisposeResources() tells the skin helper it can empty those caches and dispose of those item. This isnt strictly required, particularly if your plugin has released it reference to the skinhelper, since the unused objects will eventually be garbage collected by .net. Because cached bitmaps can be large though, it is probably advisable to call this method when closing a popup. Normal plugins screens (not popups) dont really need to bother since its fine to cache the resources until the app closes.

Quote:Should both be called in the Dispose method of each control instance?
Yes, if you've created a control manually (rather than having it created automatically using one of the supplied base classes, then you should call Dispose() on those controls. Behind the scenes this method on the controls, will construct the list of all its GBPVRUiElements it holds, and pass then to PluginHelperFactory[SIZE=2].getPluginHelper().DisposeResources(disposeList).
[/SIZE]

Quote:2) Should the control's Dispose() call element.image.Dispose(), or does the call to the PluginHelper.DisposeResources do that under the covers. (see example below)
The framework will call element.image.Dispose() on all objects submitted via PluginHelperFactory[SIZE=2].getPluginHelper().DisposeResources(disposeList).[/SIZE]

Quote:
3) It looks like the UiButton.Dispose() method is empty. Shouldn't it call the PluginHelper dispose with the normal and selected UIElements?
Yes, it should do, but isnt currently. I'll make sure this is added for the next release.

Quote:Currently all the WizControls call the xxx.image.Dispose() method for each GBPVRUiElement object in the control as well as calling the PluginHelper dispose method at the end of the controls Dispose() routine.

For example, here is the dispose method for the text box:
Code:
[COLOR=black][SIZE=2]public [/SIZE][SIZE=2]override [/SIZE][SIZE=2]void[/SIZE][SIZE=2] Dispose()[/SIZE][/COLOR]
[SIZE=2][COLOR=black]{[/COLOR][/SIZE]
[SIZE=2][COLOR=black] WizInfo.LogMessage("WizUiTextBox", "Dispose()", "Called for " + this.PlacementName);[/COLOR][/SIZE]
[COLOR=black][SIZE=2] mRenderingRequired = [/SIZE][SIZE=2]false[/SIZE][SIZE=2];[/SIZE][/COLOR]
[COLOR=black][SIZE=2] ArrayList[/SIZE][SIZE=2] disposeList = [/SIZE][SIZE=2]new[/SIZE][SIZE=2]ArrayList[/SIZE][SIZE=2]();[/SIZE][/COLOR]
[COLOR=black][SIZE=2] if[/SIZE][SIZE=2] ([/SIZE][SIZE=2]this[/SIZE][SIZE=2].normalUiElement != [/SIZE][SIZE=2]null[/SIZE][SIZE=2])[/SIZE][/COLOR]
[COLOR=black][SIZE=2]     this[/SIZE][SIZE=2].normalUiElement.image.Dispose();[/SIZE][SIZE=2] disposeList.Add([/SIZE][SIZE=2]this[/SIZE][SIZE=2].normalUiElement);[/SIZE][/COLOR]

[COLOR=black][SIZE=2]  if[/SIZE][SIZE=2] ([/SIZE][SIZE=2]this[/SIZE][SIZE=2].selectedUiElement != [/SIZE][SIZE=2]null[/SIZE][SIZE=2])[/SIZE][/COLOR]
[SIZE=2][COLOR=black]  {[/COLOR][/SIZE]
[COLOR=black][SIZE=2]      this[/SIZE][SIZE=2].selectedUiElement.image.Dispose();[/SIZE][/COLOR]
[COLOR=black][SIZE=2]      disposeList.Add([/SIZE][SIZE=2]this[/SIZE][SIZE=2].selectedUiElement);[/SIZE][/COLOR]
[SIZE=2][COLOR=black]  }[/COLOR][/SIZE]
[COLOR=black][SIZE=2]  PluginHelperFactory[/SIZE][SIZE=2].getPluginHelper().DisposeResources(disposeList);[/SIZE][/COLOR]
[COLOR=black][SIZE=2]  normalUiElement = [/SIZE][SIZE=2]null[/SIZE][SIZE=2];[/SIZE][/COLOR]
[COLOR=black][SIZE=2]  selectedUiElement = [/SIZE][SIZE=2]null[/SIZE][SIZE=2];[/SIZE][/COLOR]
[SIZE=2][COLOR=black]}[/COLOR][/SIZE]
Is that the proper way to dispose of the objects?
You dont need to worry about the element.image.Dispose(), but other than that it looks about right.
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#3
2008-01-06, 02:48 AM
Excellent. Thanks for the info...
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Images in lists using a lot of memory cncb 4 4,010 2015-11-12, 12:02 AM
Last Post: sub
  Resource management InVermont 4 2,015 2010-08-12, 06:12 PM
Last Post: InVermont
  Library Controls - which to use? McBainUK 4 2,211 2009-07-22, 01:36 AM
Last Post: reven
  .NET Graph controls McBainUK 4 2,347 2009-05-15, 06:01 PM
Last Post: McBainUK
  Closing Deactivating popups with handlePopupCallback psycik 4 1,610 2008-12-09, 08:38 AM
Last Post: psycik
  GBPVRX2.Popups.PopupBase don't close on button press psycik 2 1,447 2008-11-03, 07:35 AM
Last Post: psycik
  GBPVRX2.Popups.PopupBase - GetBackgroundArgs() psycik 5 2,109 2008-10-30, 08:49 AM
Last Post: whurlston
  GBPVRX2.Popups.PopupBase - exited, still triggering callbacks psycik 6 2,277 2008-09-30, 11:50 PM
Last Post: psycik
  What SCM (Source Control Management) system do you use? JavaWiz 3 2,035 2008-08-19, 07:28 PM
Last Post: Manderson
  Custom popups? bgowland 2 1,772 2008-05-11, 12:26 AM
Last Post: bgowland

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode