Search Unity

Destroy and clean up Unity WebGL player

Discussion in 'Web' started by Deleted User, Nov 16, 2017.

  1. Deleted User

    Deleted User

    Guest

    Is there a way to "destroy" the WebGL player and free up the resources it's using?

    I have an Angular 2(4?) website with a particular page that loads Unity WebGL games in. I've got this all working great, but I've noticed when you navigate away from that page (currently only testing in Chrome) the memory usage of that chrome tab in Task Manager does not go back down. So if I then navigate BACK to that page and load another Unity game, the memory usage goes up by that same amount again. And this will repeat every time you navigate away and back until things get very slow and likely run out of memory.

    I'm guessing this is due to Angular not actually refreshing pages when navigating but simply removing and adding DOM elements on the fly. If I manually hit refresh the memory usage shoots back down.

    So the Unity WebGL Canvas gets destroyed, but there's clearly still large amounts of data hidden somewhere that aren't getting cleaned up.
     
    chriszul and kailashvetal47 like this.
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Try waiting longer. See if the browser cleans it up when it feels like it.
     
  3. Deleted User

    Deleted User

    Guest

    I'll try that. But I've let it sit for at least 10 minutes before and I don't think it ever cleaned up. Which is a problem when after navigating to at least 2 game pages it memory usage gets high enough that the webgl player starts running rather choppy.
     
  4. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    I find something similar in Firefox where we run our app in it's own window, closing the window doesn't free up the memory you have to close the parent page, it's very annoying as it sucks up tons and tons of memory if people open more than one. Even though we only allow one window at a time Firefox can run out of memory and there is nothing it seems we can do about it.