Memory usage

Options
I've got a problem while cycling through different scene's with PUN+ in Unity 3D.
Perhaps someone knows a solution to fix this or can point me to a direction to find a solution?

This is what happens:

There are 30 different scenes in my game.
In (PUN) multiplayer you can select 'mapcycle' and each scene can be played after the other.

Now I've noticed that the RAM usage is growing and growing each scene (especially if a huge map gets loaded) and then sometimes crashes cause 'out of memory'.

Of course this first happens on 32bit systems (Windows can just adress 2GB of RAM per application), but in the end it will happen on 64bit systems too.

I've searched for any solution about RAM usage and optimization for Unity, asked Unity for help and did everything I could find about this problem, but nothing helped.

The RAM has increased to 2++ GB after 4-6 maps and then the first clients gets the crash to desktop.

Unity has no way to clear the RAM and Resource.UnloadUnusedAssets() or System.GC.Collect() doesn't help cause it just clears some megabytes but not hundrets of MB.

So my last hope is Photon.
Is there a way to 'reset the RAM to zero' before the next map/scene gets loaded?

Comments

  • Lotte
    Options
    I've noticed that this just happens in multiplayer games.

    In singleplayer the next scene gets loaded with
    Application.LoadLevel("scenename");
    wich seems to destroy and clear everything in memory.

    But in multiplayer games
    PhotonNetwork.LoadLevel(scenename);
    doesn't do this part.

    Any ideas how to clear the memory from old stuff before next scene gets loaded?
  • Lotte
    Options
    Hm...
  • Tobias
    Options
    Which Unity version are you using?

    Unity 5.3 has a new way to load scenes via the SceneManager. We use that in PhotonNetwork.LoadLevel() and it might differ from what you use otherwise.
    As Unity is going to remove LoadLevel, you should switch to using the SceneManager, too.
  • Lotte
    Lotte
    edited April 2016
    Options
    It's v4.7.0f1 and my PUN changelog says PUN v1.20.

    The problem why I didn't switch to Unity 5 was those many changes they have made. My project is realy huuuge (19GB uncompressed) and it's to much to convert the whole stuff to v5.

    The same problem with updating PUN after v1.20.
    There had been to much changes and the game didn't run anymore.
    I.E. I couldn't create a room, the loading sequence started but got stuck while loading without error messages and I couldn't figure out why.

    So I decided to stay with Unity 4 / PUN 1.20 wich works perfectly together.

    Some days ago I tried to convert to Unity 5 again so I can use the profiler.
    But it ends in a whole mess. Millions of errors and warnings and no chance to run anything. Textures, Materials, Shaders and a lot of Meshes - just destroyed.

    I know it's no problem to fix this for a small project, but my game is far to big.
    Just take a look at www.eod-game.com -Content- to see the stuff.

    Unfortunately Unity has no support.
    They run a forum and have a bug reporting system, question & answers and a contact button on their website but you never get a reply anywhere.
    I just got one reply on a forum posting and that was they deleted the thread cause I ranted about the bad support...^^

    Very frustrating after 3 years / 16828 hours of work to get absolutely no reply from Unity support.


    Enough crying, back to topic....

    Do you see a chance to 'clear' the whole RAM while loading scenes with
    PhotonNetwork.LoadLevel(scenename);

    If just PUN has to be updated I could try it again but I think it won't run anymore after the update.
  • Tobias
    Options
    PUN 1.20 is really old.
    I know it's a royal pain in the ... but I strongly suggest you update PUN and give it another go.
    We did improve memory usage by quite a bit since 1.20.

    Anything you report for v1.66 and up, we can have a look at and work on. I'm sorry, but with 1.20, we can't help.

    The changelog in the package might help you update step by step. It lists most of the changes but it sure is a lot of work despite that.
  • Tobias
    Tobias admin
    edited April 2016
    Options
    Oh and about the RAM question: In that regard, we just use Unity's features. There is nothing we do in terms of RAM and scene management. PUN is just wrapping some of Unity's features to make them work more seamlessly in multiplayer.
    I think Unity 4.7 should be doing fine though. Maybe it's a case where references are hold and keep things in mem?

    Edit: Nice bloopers video :) Lots of content! Congrats.
  • Lotte
    Lotte
    edited April 2016
    Options
    Yeah the bloopers are crazy :D

    I've imported PUN+ 1.66 now.
    Just 1 error message but I know there will be more once the first error is fixed.
    What's the best way to get support on this? Open a new thread or any other way?


    error CS1501: No overload for method `CreateRoom' takes `6' arguments
    //create the room
    PhotonNetwork.CreateRoom(newRoomName, false, true, maxPlayers, setMapName, exposedProps);
    
  • Tobias
    Options
    We changed the API quite a few times since PUN v1.20, so you need to fix those cases where you use outdated method calls.
    Unless you actually find bugs while doing this, you simply have to adjust your code and don't need to post reports ;)

    If you find anything suspicious and if the changelog does not help you find a suitable, newer API, then post a new thread, yes.