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. Dismiss Notice

Question Disabled object in scene consume memory and cpu?

Discussion in 'Scripting' started by bisewski, Sep 15, 2023.

  1. bisewski

    bisewski

    Joined:
    Jan 16, 2014
    Posts:
    153
    Hi!

    I have three objects, three heavy with textures and complex mesh. I will show only one object per time. The scene will be the same for these objects.

    What is best for performance. Create three scenes or only one setting enable and disable for the current object?

    Three scenes is bad to maintenance but if the disabled objects keeping taking cpu and memory also will be a problem.

    Thank you
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,714
    Everything "loaded" will (generally) require memory to be loaded.

    CPU is less clear, as that is only based on code that is being run, governed by rules of when stuff gets run.

    Be sure you are not impairing your forward progress by worrying about performance that ultimately won't matter.

    Computers are pretty powerful and loading three copies of whatever you contemplate may be completely acceptable memory-wise.

    Otherwise, all pre-optimize fiddles like this will impose a "forever tax" on your workflow. Once you have enough of these "forever taxes" going on, your game becomes unpleasant to do work in, gets brittle, and you get unhappy.
     
    tsukimi, Joe-Censored and bisewski like this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,028
    Performance of what?

    The time it takes to switch objects / load scenes for example may be the opposite of highest framerate or most efficient editing workflow.
     
    Kurt-Dekker and bisewski like this.
  4. wideeyenow_unity

    wideeyenow_unity

    Joined:
    Oct 7, 2020
    Posts:
    728
    I agree, this needs to be benchmarked with the profiler. Because keeping said things there, just disabled, might actually be way more performant than Instantiating and destroying. Hard to say, because this is easily a "case-by-case" basis, and no one answer will be the same, you'd need to verify with statistics(and know for sure).
     
    tsukimi, Joe-Censored and bisewski like this.