Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
retrotom
Visitor

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
0 Kudos
7 REPLIES 7
TheEndless
Channel Surfer

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)
0 Kudos
RokuKevin
Visitor

Re: Orphan objects "error"

Endless, that is correct.

--Kevin
0 Kudos
retrotom
Visitor

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.
0 Kudos
kbenson
Visitor

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!
0 Kudos
TheEndless
Channel Surfer

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)
0 Kudos
retrotom
Visitor

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.
0 Kudos
RokuKevin
Visitor

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
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.