MediaPortal Forums HTPC/MediaCenter

Go Back   MediaPortal Forum » MediaPortal 1 » Help on Development » General Development (no feature request here!)


General Development (no feature request here!) You were able to fix an issue, or improved a feature? Post it here.

Reply
 
Thread Tools Display Modes
Old 2005-12-18, 15:54   #1 (permalink)
Portal Developer
 
ziphnor's Avatar
 
Join Date: Aug 2005
Location: Copenhagen
Age: 29
Posts: 709
Thanks: 0
Thanked 9 Times in 6 Posts

Country:

My System

Default Question on garbage collection

Hi,

Being annoyed with the problems with the Compress plug-in i decided to try to fix it. The problem is that whenever a transcoding job is in progress, the call GC.GetTotalMemory(true) doesnt return(at least within any reasonable time) when called in GUIWindow OnMessage when it gets a GUI_MSG_WINDOW_DEINIT message. This causes the effect that if you try to navigate away from the current window while the job is in progress, the gui blocks/locks.

What i would like to know is a bit more about what the GC calls does. According to the documentation for GC.GetTotalMemory:

Code:
        //
        // Summary:
        //     Retrieves the number of bytes currently thought to be allocated. A parameter
        //     indicates whether this method can wait a short interval before returning,
        //     to allow the system to collect garbage and finalize objects.
        //
        // Parameters:
        //   forceFullCollection:
        //     A Boolean value which, if true, indicates that this method can wait for garbage
        //     collection to occur before returning.
        //
        // Returns:
        //     A number that is the best available approximation of the number of bytes
        //     currently allocated in managed memory.
From this it seems that it will a "short interval" before returning, but this doesnt seem to be the case. However this only happens when a transcoding job is in progress.

I fixed the problem in my local installation by changing the call to GC.GetTotalMemory(false). Could the explanation be that the call waits for GC to finish, but GC might run with a very low priority so that it wont run because the transcoding job is eating up all the CPU time, locking the GUI which is waiting for it?

I would also like to know why there are 3 call to GC.collect in a row preceding the call to GC.GetTotalMemory, why doesnt one suffice?
ziphnor is offline   Reply With Quote
Old 2005-12-18, 16:54   #2 (permalink)
Retired Team Member
 
Join Date: Dec 2005
Posts: 77
Thanks: 0
Thanked 2 Times in 1 Post


Default

Generally speeking, it sounds like a resource contention issue. The transcoding is running in a seperate thread locking and unlocking resources and probably allocating/deallocating (indirectly) a lot of memory.

One call to GC.Collect() should suffice for freeing all unreferenced memory. I don't know why three calls would be neccessary. The GC.GetTotalMemory call will need to temporarily lock any managed memory resources in order to obtain a snapshot of their size. My guess is that the transcoding thread is accessing a sufficient number of memory resources that it is gaining far more access to them than the GetTotalMemory call can, thus slowing down the call to GetTotalMemory.

Just my 2 cents,
Drak
draktheas is offline   Reply With Quote
Old 2005-12-18, 18:01   #3 (permalink)
Portal Developer
 
ziphnor's Avatar
 
Join Date: Aug 2005
Location: Copenhagen
Age: 29
Posts: 709
Thanks: 0
Thanked 9 Times in 6 Posts

Country:

My System

Default

Quote:
Originally Posted by draktheas
My guess is that the transcoding thread is accessing a sufficient number of memory resources that it is gaining far more access to them than the GetTotalMemory call can, thus slowing down the call to GetTotalMemory.
You are probably right, its either memory of CPU resource contention. Isnt the logical consequence of this to stop calling GC.GetTotalMemory(true) at this point in the code? I mean, as far as i can tell its only there for debugging purposes, ie printing the amount of used memory to the log file. Also i feel that in general its poor style to have the GUI stall waiting for the garbage collector.

Im new to messing around with the MP code, should i just submit a patch for the GUIWindow.cs file at sourceforge?
ziphnor is offline   Reply With Quote
Old 2005-12-18, 20:47   #4 (permalink)
Retired Team Member
 
Join Date: Dec 2005
Posts: 77
Thanks: 0
Thanked 2 Times in 1 Post


Default

That's probably what I would do. But I am pretty new here, so I am not sure what the procedure for submitting a patch would be.

Any Dev's want to take a stab at that one?

Drak
draktheas is offline   Reply With Quote
Old 2005-12-19, 17:33   #5 (permalink)
Portal Developer
 
ziphnor's Avatar
 
Join Date: Aug 2005
Location: Copenhagen
Age: 29
Posts: 709
Thanks: 0
Thanked 9 Times in 6 Posts

Country:

My System

Default

Quote:
Originally Posted by draktheas
That's probably what I would do. But I am pretty new here, so I am not sure what the procedure for submitting a patch would be.

Any Dev's want to take a stab at that one?

Drak
Well i tried creating a patch at sourceforge, i hope it did it correctly. I also created a seperate fix for the BlueTwo mytvcompress.xml skin which had set the wrong type for a control causing a null pointer exception.
ziphnor is offline   Reply With Quote
Old 2005-12-19, 23:13   #6 (permalink)
Retired Team Member
 
tomtom21000's Avatar
 
Join Date: Apr 2004
Location: Germany
Posts: 990
Thanks: 5
Thanked 4 Times in 4 Posts

My System

Default

Quote:
Originally Posted by ziphnor
[
Well i tried creating a patch at sourceforge, i hope it did it correctly. I also created a seperate fix for the BlueTwo mytvcompress.xml skin which had set the wrong type for a control causing a null pointer exception.
Just wanted to say that it went almost right.
Good description, but there are no files attached to your patches on sf.
I am no programmer, so I can“t say much to the patches themselves.

tomtom
__________________
tomtom21000 is online now   Reply With Quote
Old 2005-12-20, 17:14   #7 (permalink)
Portal Developer
 
ziphnor's Avatar
 
Join Date: Aug 2005
Location: Copenhagen
Age: 29
Posts: 709
Thanks: 0
Thanked 9 Times in 6 Posts

Country:

My System

Default

Quote:
Originally Posted by tomtom21000
Just wanted to say that it went almost right.
Good description, but there are no files attached to your patches on sf.
I am no programmer, so I can“t say much to the patches themselves.
However i see that they are now listed as closed, and looking in the CVS both patches seem to have been applied( the memory usage is now not printed at all, GC.collect is not called at all, and the skin button is correctly specified). I guess someone(most likely yamp, based on who closed it) read the description and made the changes based on that.

I didnt forget the files, however, i didnt notice the checkbox you had to check of to actually get it to upload the file
ziphnor is offline   Reply With Quote
Old 2005-12-21, 08:55   #8 (permalink)
Retired Team Member
 
Join Date: Sep 2004
Location: Finland
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts


Default

Hi,

Thanks for your intrest of mediaportal. If you create other fixes i have found these tips useful when submitting code to the project.

1. Submit whole files not just diffs.
2. Open topic on forums with header [patch] short explanation
3. And if possibe try to contact devs on irc (been silent lately tho)
4. When submitting file describe your patch as much as possible.

Hope these hints help you to submit your next patch.

CoolHammer
__________________
AMD Sempron 2400+ / ATI AIW 9000 Pro / Samsung 120Gb / Asus A7N8X-VM/400 / Windows XP pro Fi /LG 32LP1 LCD TV connected with DVI /Sony amp connected with S/PDIF
CoolHammer is offline   Reply With Quote
Old 2005-12-21, 10:11   #9 (permalink)
Portal Developer
 
ziphnor's Avatar
 
Join Date: Aug 2005
Location: Copenhagen
Age: 29
Posts: 709
Thanks: 0
Thanked 9 Times in 6 Posts

Country:

My System

Default

Quote:
Originally Posted by CoolHammer
Hi,

Thanks for your intrest of mediaportal. If you create other fixes i have found these tips useful when submitting code to the project.

1. Submit whole files not just diffs.
2. Open topic on forums with header [patch] short explanation
3. And if possibe try to contact devs on irc (been silent lately tho)
4. When submitting file describe your patch as much as possible.

Hope these hints help you to submit your next patch.

CoolHammer
I got 1 and 4 covered this time(except i messed up in actually attaching the files, but then the descriptions were good enough that the patch could be done without the files , i wasnt aware of the IRC developer chat nor the [patch] thread concept. Thanks for the information, i will heed you advice the next time i need to submit to submit a patch.
ziphnor is offline   Reply With Quote
Reply

Bookmarks

Tags
collection, garbage, question

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about hardware support of a Sabrent SBT-TVFM M4GIC General Support 3 2008-05-26 07:39
last.fm plugin: use last.fm tags for local music collection tomtom21000 Improvement Suggestions 1 2006-11-13 23:00
.wav File Music Collection randomblondeboy General Support 0 2006-04-17 05:52
Music scan misses 'Numerical' and/or 'Collection' Albums etc. Funky 0.2.0.0 Release Candidate 1 1 2005-11-27 21:52
Question about the hauppauge 350 tv-out software? Th3Eagle OffTopic 4 2005-08-02 22:19


All times are GMT +1. The time now is 01:29.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 Protected by Akismet Blog with WordPress