Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Memory use - deactivate vs destroy?

Discussion in 'Editor & General Support' started by DocSWAB, Feb 17, 2008.

  1. DocSWAB

    DocSWAB

    Joined:
    Aug 28, 2006
    Posts:
    615
    We have an object made with a cylinder mesh that we use to help place target points in the IDE that uses a 1024 texture (mostly just convenience). There are perhaps 20-30 of these objects in the scene.

    Right now they are set to be deactivated on Start so that they are not visible.

    My question is, in terms of main system memory overhead, is it better to deactivate or Destroy them (there is no user option to turn them back on again once the scene is running). I realize that the objects are not rendering when they are disabled, but I'm wondering about the texture taking up space in RAM still (assuming that no other objects are using this texture).

    Is the texture being held in VRAM anyway as well?

    Thanks
     
  2. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Broader question: Is there any way to get Unity to report the ammount of RAM and VRAM being used at any given time? Then he could do his own memory check to settle it.
     
  3. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    You can profile your app with Shark.

    About deactivating vs destroy, remember that while an object exists, it is still completely stored in RAM.

    The only use, performance-wise, of deactivating is to prevent rendering calculations for speed, and VRAM use. The object's transform is still tracked, along with everything else for the most part.

    So, when in doubt, Destroy. Then Unity can clean up and free the memory used by the object, (or pass it to another object if they use pooling).

    That being said, it shouldn't be an issue with just a few objects, and VRAM wouldn't be used unless it is being rendered.

    HTH, and UT can clear it up if needed.
    -Jeremy