Skip to content

Memory leak occurs when "Stitched Ad" integration is used. #34

@azat-econify

Description

@azat-econify

Expected Behavior

When a roku channel is using mux analytics with stitched ads, the channel should not be leaking memory resulting in a host of performance issues including not only channel, but device crash.

Current Behavior

A roku channel using mux analytics with stitched ads leaks memory. The channel becomes slow and the device crashes.

Possible Solution

Prevent the ContentPosition event coming from RAF from setting the rafEvent field with data, since that event does not get taken advantage of in the rafEventHandler function of mux-analytics.brs. The adIface object is quite large and its size contributes to the memory usage. I will try to find out details in regards to the logic of garbage collection in the getData() method of roSGNodeEvent.

Steps to Reproduce

  1. Clone this repo and launch the sample channel.
  2. Select "Stitched Ad" from the menu and load the video.
  3. When the video starts, run chanperf in the SG debugger to get the channel memory usage:
    Start: channel: mem=58272KiB{anon=17888,file=31868,shared=8516,swap=0},%cpu=6{user=4,sys=3}
    1 minute in: channel: mem=102088KiB{anon=19204,file=31868,shared=51016,swap=0},%cpu=4{user=2,sys=2}
    5 minutes in: channel: mem=116900KiB{anon=26480,file=31952,shared=58468,swap=0},%cpu=3{user=2,sys=1}
    10 minutes in: channel: mem=126612KiB{anon=36180,file=31952,shared=58480,swap=0},%cpu=3{user=2,sys=1}
    Finish: channel: mem=139444KiB{anon=48924,file=32016,shared=58504,swap=0},%cpu=2{user=1,sys=1}
  4. Compare the results to selecting the "Full RAF Integration" option.
    Start: channel: mem=57912KiB{anon=19952,file=31780,shared=6180,swap=0},%cpu=6{user=3,sys=2}
    1 minute in: channel: mem=110184KiB{anon=19952,file=31780,shared=58452,swap=0},%cpu=3{user=1,sys=2}
    5 minutes in: channel: mem=110404KiB{anon=20096,file=31836,shared=58472,swap=0},%cpu=2{user=2,sys=1}
    10 minutes in: channel: mem=110404KiB{anon=20096,file=31836,shared=58472,swap=0},%cpu=2{user=2,sys=1}
    Finish: channel: mem=110404KiB{anon=20096,file=31836,shared=58472,swap=0},%cpu=2{user=1,sys=1}
    Note: The channel was restarted in between runs to get the most accurate starting RAM usage. When the leaky run's video was finished and the main menu was displayed chanperf output was:
    channel: mem=82748KiB{anon=49844,file=32204,shared=700,swap=0},%cpu=6{user=4,sys=2}

On our channel this leak is on average @ 2.8MB/minute and this results in that after approximately 120 minutes of video streaming the device (3930X - 512MB RAM) runs out of RAM and swap space triggering a device reboot.

Context (Environment)

Test device: 3930X. Firmware 10.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions