Skip to main content
November 18, 2017
Question

Flash Player runs out of memory when streaming on Crunchyroll

  • November 18, 2017
  • 1 reply
  • 452 views

I'm having problems with the sheer amount of memory it's using.  It's supposed to use a set %, but I checked my task manager and found it using 2.8gigs out of my total 4 gigs.  It ran so slow it eventually stopped working because it had used ALL my memory.  All I was doing was watching anime via Crunchyroll.

I'd say there is a major memory leak.

    This topic has been closed for replies.

    1 reply

    jeromiec83223024
    Inspiring
    November 23, 2017

    This doesn't really have anything to do with the original post, so I'm going to branch it out to its own thread.

    There's a long-standing thing where a number of video providers will allocate NetStream objects for commercials, but they never release them.  It's unforutnately a pretty common mistake, although it's less common now as people switch to HTML5 video for streaming.  Long story short, ActionScript is a garbage collected language, and the virtual machine periodically runs through and culls unused objects to reclaim that memory.


    What happens in practice is that every single commercial that gets loaded is stored, in its entirety, in memory.  If the commercial was freed, we'd just free that memory up whenever the GC ran.  Instead, because it's left in use by the video player, it's not available for the garbage collector to free.  Eventually, you watch enough commercials that memory fills up and we'll throw an out of memory error and exit.

    Because Flash Player is a language runtime and not a video player, (i.e. you can *write* a video player using Flash, but we only supply the primitives that make that possible), we don't have any control over how the video player on a particular website behaves.  It also means that any change we make affects every single website that uses Flash video.

    The only reasonable "fix" here is to limit the number of netstream objects that can be created in a given instance.  In essence, we get to choose between living with poorly implemented video players that allocate an unbound number of video objects in memory, or we could impose a hard upper limit, such that after 10-15 commercials, playback just dies.

    We actually thought very seriously about imposing that limit, but came to the conclusion that both options are terrible; however, adding a hard limit in this way would ruin the experience for more people than are currently inconvenienced by the out of memory issue.

    You're more than welcome to point the folks at Crunchyroll to this thread.  We publish a lot of information about how to implement streaming video correctly, and we'd be more than happy to help them.  In the very unlikely event that they find that this is actually a language-level issue, we'd be happy to work with them to get it figured out.