Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Game gets progressively slow on mobile

Discussion in '2D' started by Abulero, Jan 19, 2023.

  1. Abulero

    Abulero

    Joined:
    Dec 18, 2020
    Posts:
    9
    I have a 2D game with waves of monsters. The monsters have particle effects and also shoot things at the character.
    After even 1 minute of playing, the game goes from high fps to <5 fps.
    I ran it on Unity with Analysis on and generated the attached image. The screenshots were taken with the same game objects on the scene: ~10 monsters and the player attacking eachother. On the left, the initial analysis. On the right, the analysis after 30min.

    Why is the memory increasing? How can I solve this?

    Notes: no game objects keeps being added infinitely on the scene. The number of game objects is stable.
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    Are you making custom materials or render textures or really any kind of asset at all on the fly?

    The basic steps to this are:

    - find what is in that extra 2gb of used RAM
    - stop doing that :)

    If you cannot get good insight from the profiler, start turning off features of your game that might be doing this.

    When you identify the culprit area, go in and dig deeper and fix / modify it.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,064
    Does the device get noticeably hot? A lot of mobiles are prone to overheating and when that happens they start underclocking stuff and performance drops, although 1 minute is probably not enough time.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    That is also a very good callout Acid... but I'd look first at the 2gb of RAM that gets hoovered up from left screenshot to right screenshot! :)
     
  5. Abulero

    Abulero

    Joined:
    Dec 18, 2020
    Posts:
    9
    I checked that. My phone was indeed fairly warm. But then I let some cold water run on the back and it became quite cold. No fps changes.

    @Kurt-Dekker I'm not creating any textures on the fly. But I think your suggestion is the way to go. I'll start digging to find what the source of the leak is. Thanks !
     
  6. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Isn't that 2GB taken by profiler itself? Last item in the bottom section is Profiler:0.5GB on the left and Profiler:2,5GB on the right. But that doesn't really explain FPS drop when not using profiler. It would be good verify what happens to memory usage when not using profiler using adb shell or some other method.