Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Addressables.ReleaseInstance is not deleting object

Discussion in 'Addressables' started by Jribs, Dec 5, 2019.

  1. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    154
    I have discovered that
    Addressables.ReleaseInstance(go)
    is not destroying instances that are not actually addressables.

    We have been told that it is supposed to catch the non addressables and call
    Destroy()
    on them but it doesn't seem to be working.

    Is this a known bug?
     
  2. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    762
    Hey @Jribs I imagine the result of your ReleaseInstance call is false, meaning it wasn't able to release the object you passed in. In the past we would destroy GameObjects for you if they weren't Addressable but I think that led to some awkward states and other various issues (I don't have any details on those issues atm) so we ended up removing that.

    If you have a mix of Addressable instantiated GameObjects and regular instantiated GameObjects and you could be releasing objects from either pool and you're not sure which, I'd suggest something like

    Code (CSharp):
    1. if(!Addressables.ReleaseInstance(myObject))
    2.      Destroy(myObject);
    or something to that effect.
     
    socialtrens likes this.
  3. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    154
    @DavidUnity3d great thanks that is good to know.

    There are various sources around here that tell us to just replace every Destroy(myObject) with ReleaseInstance(myObject). If that is no longer true, that should probably be updated in the docs or something.
     
  4. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    762
    Yes, very good point. That does need to be updated in the docs. I appreciate you pointing that out.
     
  5. Nithinsvs

    Nithinsvs

    Joined:
    Sep 3, 2017
    Posts:
    29
    What about ref count maintained by addressables in this case ?