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

How to determine where memory is allocated?

Discussion in 'Scripting' started by d1mentor, Apr 26, 2022.

  1. d1mentor

    d1mentor

    Joined:
    Jun 27, 2021
    Posts:
    2
    Hey! There is something wrong with my player loop, I made a mistake somewhere. I don't understand where
    memory is allocated here. If anyone has any ideas on how to track this, I'd be very grateful.
    upload_2022-4-26_9-14-58.png
    It doesn't happen every frame.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,015
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,204
    It's somewhere inside Player.FixedUpdate(). If you enable deep profiling, it'll give you a lot better information about this (although the game runs slower!)

    One thing to be very aware of is that some methods have editor-only allocations, GetComponent<> being the main offender. Either profile builds, or rewrite code to use TryGetComponent if that's a problem.
     
    Bunny83 likes this.
  4. d1mentor

    d1mentor

    Joined:
    Jun 27, 2021
    Posts:
    2
    thank you very much, didn't know about deep profiling. It really helped me find memory allocations.