retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2011
07:26 AM
Orphan objects "error"
I've been noticing that the debugger sometimes says "Error! Found X orphaned objects". Does the relate to errors in our user code? And if so, is it possible to get more information so that we can clean it up better?
Thanks,
RT
Thanks,
RT
7 REPLIES 7

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2011
09:56 AM
Re: Orphan objects "error"
As I understand it, "orphaned objects" are just circular references that the garbage collector wasn't able to clean up during execution. I don't think they're actual errors.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

RokuKevin
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2011
08:15 PM
Re: Orphan objects "error"
Endless, that is correct.
--Kevin
--Kevin
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011
08:17 AM
Re: Orphan objects "error"
"RokuKevin" wrote:
Endless, that is correct.
--Kevin
That makes sense, but I was wondering if there are any side affects because of that. If so, what (if anything) can we do about it? I don't know what a "high" number is for the number of objects that were orphaned -- but I consistently see a number above 2K. So (to me), that sounds like a lot of orphaned objects. I just want to make sure that we're not "leaking" all over the place. If we are, I'd like to be able to call something "GC.Collect()" and clean up when there's little/no user interaction.
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011
09:47 AM
Re: Orphan objects "error"
"retrotom" wrote:
That makes sense, but I was wondering if there are any side affects because of that. If so, what (if anything) can we do about it? I don't know what a "high" number is for the number of objects that were orphaned -- but I consistently see a number above 2K. So (to me), that sounds like a lot of orphaned objects. I just want to make sure that we're not "leaking" all over the place. If we are, I'd like to be able to call something "GC.Collect()" and clean up when there's little/no user interaction.
It probably has more to do with the fact that the home button immediately kills the channel, and there's not a normal out of scope cleanup of variables. It probably considers everything as orphaned.
I'm not positive, but I believe before they had the home button killing the channel automatically it didn't do that. It used to send a msg that could be caught. They changed the behavior so a misbehaving channel couldn't ignore home button presses.
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011
09:54 AM
Re: Orphan objects "error"
"kbenson" wrote:
It probably has more to do with the fact that the home button immediately kills the channel, and there's not a normal out of scope cleanup of variables. It probably considers everything as orphaned.
I'm not positive, but I believe before they had the home button killing the channel automatically it didn't do that. It used to send a msg that could be caught. They changed the behavior so a misbehaving channel couldn't ignore home button presses.
I don't think so. I get the same-ish number of "orphans" regardless of whether I use Home or I back out screen by screen. Many of my "classes" use callbacks to notify the screen/class that created them, so the child references the parent, hence the circular reference. I believe, when that screen closes, the garbage collector can't reconcile the circular reference definitively enough to know whether to clean it up or not, so it becomes orphaned. I do wonder if there are significant memory implications to that model and/or if there's a way to tell the system that it's safe to clean up.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
retrotom
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2011
02:26 PM
Re: Orphan objects "error"
"TheEndless" wrote:
I believe, when that screen closes, the garbage collector can't reconcile the circular reference definitively enough to know whether to clean it up or not, so it becomes orphaned. I do wonder if there are significant memory implications to that model and/or if there's a way to tell the system that it's safe to clean up.
That's my concern as well. I recall that on earlier firmware revisions that my channel would just crash for no reason sometimes. Sometimes it would freeze and I'd be unable to enter other channels or the channel store. I'd have to unplug power and restart it. I was wondering if it my be useful and/or possible to just have the framework/platform/roku run garbage collection whenever users hit the "main home" screen or something. Looking at the debugger -- the collection time is small enough to warrant such an action. Then again, with the newer firmwares...I'm seeing fewer stability issues -- so it might not be such a cause for concern.

RokuKevin
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2011
11:27 AM
Re: Orphan objects "error"
If your app exits normally, the number of orphans should be zero. The garbage collector works by building a reference graph. The garbage collector may become fooled by objects that are referenced but not accessible by any start references in scope or global m. scope.
So check your code for circular references....
--Kevin
So check your code for circular references....
--Kevin