I have an channel that plays video files from a usb device. It is working great most of the time, however, the video playback freezes and the Roku 3 restarts. I've not been able to find a case that consistently reproduces the crash, but I would like to log out memory usage if thats possible to monitor the debug console while using the channel so I can rule out a memory leak... or hopefully pin-point the leak.
Also, what is the best way to free memory or free up a variable that is no longer needed?
You can call runGarbageCollector() to free up memory from released variables at any time, normal garbage collection runs on a periodic basis. If it is video memory, releasing all sprites, regions and bitmaps and then calling screen.finish() or screen.swapbuffers() should release that memory. Depending on the model of Roku you are using, SetMaxVideoDecodeResolution may help if you are using roVideoPlayer
If you are storing anything in tmp:/ that isn't being used you could delete that as well.
"MattBates" wrote: let us know if you find a better solution!
Well, you can use the globaly pre-defined function RunGarbageCollector() in your code. It's marginally better in that it does the same like console "gc" but there is no need to interrupt the program, it can just check and e.g. print periodically RunGarbageCollector().count . Doc on it shows great example on how orphans are created btw, kudos.