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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Difference between object on scene and pooled object

Discussion in 'Getting Started' started by monsterrungame, Jun 29, 2020.

  1. monsterrungame

    monsterrungame

    Joined:
    Sep 27, 2019
    Posts:
    15
    Hello
    I've a question about optimisation. Is there any difference in optimisation/memory between object that I put on scene and set SetActive(false) and from a pooled one instantiated by a script and also SetActive(false).
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    There's no difference; an object gets instantiated in the scene, it will create an allocation call and have a reference in memory.

    The purpose of object pooling is to save on rapid allocation calls for frequently used objects, by instantiating a number of objects all at once, getting all the allocation calls out of the way, and re-using them.
     
  3. monsterrungame

    monsterrungame

    Joined:
    Sep 27, 2019
    Posts:
    15
    thanks for the information
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Object pooling is a performance optimization, not a memory optimization. Calling SetActive is faster than calling Instantiate, basically.