NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 37 38 39 40 41 … 93 Next »
tracking down high memory usage in skiptool

 
  • 0 Vote(s) - 0 Average
tracking down high memory usage in skiptool
pastro
Offline

Posting Freak

Posts: 1,885
Threads: 128
Joined: Jul 2006
#1
2007-12-01, 03:08 AM
having a little trouble in skiptool that when I keep allocating bitmaps as local variables the memory and commit charge keeps growing until finally the memory drops back but the commit charge still stays very high. Any pointers about how one can cause .net to handle this more gracefully?
GBpvr PC: Intel Celeron 1.8 Ghz. 768 Mb WinXp Home Sp2
Video: Diamond 128 Mb 9550
Capture Cards: PVR-150 & PVR-150 MCE w/fm + 2x MVP
Author of: BurnDVDX2 and Skiptool
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#2
2007-12-01, 03:10 AM
You can call Dispose() on bitmap when you're finished with it.
pastro
Offline

Posting Freak

Posts: 1,885
Threads: 128
Joined: Jul 2006
#3
2007-12-01, 03:26 AM
Yeah I did that in much of my code. When I was returning a bitmap though, I didn't. Back a few versions ago you helped .net reclaim memory somehow, fixing a problem that I had with win2k. Is there a trick there to get windows to return the memory once it is freed?
GBpvr PC: Intel Celeron 1.8 Ghz. 768 Mb WinXp Home Sp2
Video: Diamond 128 Mb 9550
Capture Cards: PVR-150 & PVR-150 MCE w/fm + 2x MVP
Author of: BurnDVDX2 and Skiptool
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#4
2007-12-01, 03:38 AM
How are you drawing the bitmap on the screen? If you're creating GBPVRUiElement for this picture, then you need to dispose of it too with something like:

Code:
ArrayList disposeList = new ArrayList();
    disposeList.Add(element);
    PluginHelperFactory.getPluginHelper().DisposeResources(disposeList);
pastro
Offline

Posting Freak

Posts: 1,885
Threads: 128
Joined: Jul 2006
#5
2007-12-01, 04:32 AM
From the framework I get a getimage callback. I return the bitmap from the call. Here is the section of code that generates the getimage callback.



Code:
[SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=2] getPostBackgroundRenderList()[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008000]//logMessage("getPostBackgroundRenderList()", "called");[/COLOR][/SIZE]
[SIZE=2][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=2] renderList = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=2]();[/SIZE]
[SIZE=2]renderList = [/SIZE][SIZE=2][COLOR=#0000ff]base[/COLOR][/SIZE][SIZE=2].getPostBackgroundRenderList();[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (![/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].deactivating)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=2] pluginControlList = ctlMgr.ControlList;[/SIZE]
[SIZE=2][COLOR=#0000ff]foreach[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#2b91af]AWizUiControl[/COLOR][/SIZE][SIZE=2] ctl [/SIZE][SIZE=2][COLOR=#0000ff]in[/COLOR][/SIZE][SIZE=2] pluginControlList)[/SIZE]
[SIZE=2]renderList.AddRange(ctl.GetRenderList());[/SIZE]
[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].activePopup != [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]renderList.AddRange((([/SIZE][SIZE=2][COLOR=#2b91af]IUiTask[/COLOR][/SIZE][SIZE=2])[/SIZE][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=2].activePopup).GetRenderList());[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] renderList;[/SIZE]
[SIZE=2]}[/SIZE]
GBpvr PC: Intel Celeron 1.8 Ghz. 768 Mb WinXp Home Sp2
Video: Diamond 128 Mb 9550
Capture Cards: PVR-150 & PVR-150 MCE w/fm + 2x MVP
Author of: BurnDVDX2 and Skiptool
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#6
2007-12-01, 04:36 AM
I have no idea what the Wiz controls do behind the scenes, so I cant really tell you anything from that code. It really depends what the Wiz stuff is doing with the image that is returned from that callback.
pastro
Offline

Posting Freak

Posts: 1,885
Threads: 128
Joined: Jul 2006
#7
2007-12-01, 04:58 AM
sub Wrote:I have no idea what the Wiz controls do behind the scenes, so I cant really tell you anything from that code. It really depends what the Wiz stuff is doing with the image that is returned from that callback.

Fair enough, I'll check with JavaWiz. Thanks for the help.
GBpvr PC: Intel Celeron 1.8 Ghz. 768 Mb WinXp Home Sp2
Video: Diamond 128 Mb 9550
Capture Cards: PVR-150 & PVR-150 MCE w/fm + 2x MVP
Author of: BurnDVDX2 and Skiptool
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#8
2007-12-01, 06:40 AM
sub Wrote:How are you drawing the bitmap on the screen? If you're creating GBPVRUiElement for this picture, then you need to dispose of it too with something like:

Code:
ArrayList disposeList = new ArrayList();
    disposeList.Add(element);
    PluginHelperFactory.getPluginHelper().DisposeResources(disposeList);
Where should that code be called? In the WizUi elements, I've created a Dispose method like this:

Code:
[SIZE=1][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]override[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=1] Dispose()
{
Logger.Verbose([/SIZE][SIZE=1][COLOR=#a31515]"WizUiButton.Dispose(): "[/COLOR][/SIZE][SIZE=1] + [/SIZE][SIZE=1][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=1].placementName);
mbRenderingRequired = [/SIZE][SIZE=1][COLOR=#0000ff]false[/COLOR][/SIZE][SIZE=1];
[/SIZE][SIZE=1][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=1] disposeList = [/SIZE][SIZE=1][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=1][COLOR=#2b91af]ArrayList[/COLOR][/SIZE][SIZE=1]();
[/SIZE][SIZE=1][COLOR=#008000]//this.skinHelper.DisposeResources(); // test
[/COLOR][/SIZE][SIZE=1][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=1] ([/SIZE][SIZE=1][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=1].normalUiElement != [/SIZE][SIZE=1][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=1])
disposeList.Add([/SIZE][SIZE=1][COLOR=#0000ff]this[/COLOR][/SIZE][SIZE=1].normalUiElement);
PluginHelperFactory.getPluginHelper().DisposeResources(disposeList);
}
[/SIZE]
Does .net call this method automatically, or do I need to call it at some point in the cycle?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,789
Threads: 769
Joined: Nov 2003
#9
2007-12-01, 07:30 AM
Quote:Where should that code be called?
In pastro's case if he (or Wiz framework) is ending up creating a new GBPVRUiElement for each bitmap video frame he is trying to display, then the element should be dispose when he creates the new one (since the old one is no longer required). The reason this is required is because the element has a handle to an underlying direct3d texture which is unmanaged and wont be garbage collected.

His probably may or may not be related to this though. If he is creating a large number of bitmaps it may just be the .net garbage collection / memory manager hasnt got around to reusing any memory as load subsequent images.

----
In most of my screens I dont have bother disposing of stuff since at first use I leave it created/cached for future reuse. For example, buttons or list items in the Recording screen etc.

The place I do explicitly try to explicitly dispose of stuff is when I know that it wont be reused - like popups and the resources they use.
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#10
2007-12-04, 11:59 PM (This post was last modified: 2007-12-05, 12:07 AM by JavaWiz.)
I've attached a modified WizUiHelper.DLL with changes to WizUiList. I've added a private method DisposeListCache() which is called whenever either the list .SetItemList() is called (it is internally called in the .Clear() method)
Code:
[COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]void[/COLOR] DisposeListCache()
{
[COLOR=#0000ff]   if[/COLOR] (itemUiCache.Count > 0)
    {
[COLOR=#2b91af]       WizInfo[/COLOR].LogMessage([COLOR=#a31515]"WizUiList"[/COLOR], [COLOR=#a31515]"DisposeListCache()"[/COLOR], [COLOR=#a31515]"Called for "[/COLOR] + [COLOR=#0000ff]this[/COLOR].PlacementName + [COLOR=#a31515]" "[/COLOR] + itemUiCache.Count + [COLOR=#a31515]" entries disposed"[/COLOR]);
[COLOR=#2b91af]       ArrayList[/COLOR] disposeList = [COLOR=#0000ff]new[/COLOR] [COLOR=#2b91af]ArrayList[/COLOR]();
[COLOR=#0000ff]       foreach[/COLOR] ([COLOR=#2b91af]GBPVRUiElement[/COLOR] element [COLOR=#0000ff]in[/COLOR] [COLOR=#0000ff]this[/COLOR].itemUiCache.Values)
        {
            disposeList.Add(element);
        }
        itemUiCache.Clear();
        itemUiCache = [COLOR=#0000ff]new[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR]();
        itemUiCacheAging.Clear();
        itemUiCacheAging = [COLOR=#0000ff]new[/COLOR] [COLOR=#2b91af]ArrayList[/COLOR]();
        itemUiElementHashMap.Clear();
        itemUiElementHashMap = [COLOR=#0000ff]new[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR]();
        clickableRegions.Clear();
        clickableRegions = [COLOR=#0000ff]new[/COLOR] [COLOR=#2b91af]Hashtable[/COLOR]();
[COLOR=#2b91af]       PluginHelperFactory[/COLOR][SIZE=1][SIZE=2].getPluginHelper().DisposeResources(disposeList);[/SIZE]
    }
}
[/SIZE]

The idea is that whenever we change the full list, we will release all elements associated with the prior list.

If this seems to help, I will release to the wiki.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (4): 1 2 3 4 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tuner status & disk usage mikaelgu 2 2,976 2017-04-10, 04:51 PM
Last Post: mikaelgu
  Images in lists using a lot of memory cncb 4 4,102 2015-11-12, 12:02 AM
Last Post: sub
  high res (256x256+) npvr icon? reven 15 6,010 2013-09-01, 05:13 AM
Last Post: psycik
  Tracking Live TV status imilne 2 2,283 2011-07-13, 07:04 PM
Last Post: imilne
  PopupMessageBox usage McBainUK 2 1,638 2009-01-20, 06:06 PM
Last Post: whurlston
  Skiptool sometimes hacks out the middle mkenyon2 10 3,398 2008-11-24, 05:31 PM
Last Post: mkenyon2
  pastro, is SkipTool broken with WizUiHelper v1.0.17.0? mkenyon2 5 2,281 2008-06-02, 08:16 PM
Last Post: mkenyon2
  SkipTool, do you use the GBPVR SQLite database? mkenyon2 1 1,628 2008-04-21, 07:30 PM
Last Post: pastro
  TV is recorded at high speed!! idkpmiller 4 2,288 2008-04-20, 01:11 AM
Last Post: idkpmiller
  More On Memory Management Ommina 2 1,751 2008-01-09, 06:54 AM
Last Post: Ommina

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

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

Linear Mode
Threaded Mode