Search Unity

Unloading X unused Assets to reduce memory usage - How to disable?

Discussion in 'iOS and tvOS' started by SGDavid, Feb 1, 2011.

  1. SGDavid

    SGDavid

    Joined:
    Mar 17, 2010
    Posts:
    12
    I've seen a few other posts similiar to this, but I figured I'd put out my exact details.
    Basically, it seems Unity is cleaning up a GameObject I need to stick around!

    Here is the log:
    Code (csharp):
    1. Unloading 1 unused Assets to reduce memory usage. Loaded Objects now: 242.
    2. Unloading 1 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)
    3. [Switching to thread 11523]
    4. Program received signal:  “EXC_BAD_ACCESS”.
    5. Current language:  auto; currently c++
    6. warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
    7. Xcode could not locate source file: RakNetTypes.h (line: 320)
    8.  
    I have a singleton manager class that does not inherit from anything.
    I have the following in the singleton:

    Code (csharp):
    1.  
    2. // Declared
    3. private static GameObject _FBPluginObject;
    4. ...
    5. // Later...
    6. _FBPluginObject = new GameObject();
    7. _FBPluginObject.name = "iOS_FBCallbacks";
    8. _FBPluginObject.AddComponent("iOS_FBCallbacks")
    9.  
    The OnDisable() for the iOS_FBCallbacks class (which is a MonoBehavior) is getting called when the above.
    Is there any way to mark a game object as "do not delete?" I already called DontDestroyOnLoad(this) in it's Awake() function...

    Thanks for any ideas!
     
    LaserWzzrd likes this.
  2. Barbur

    Barbur

    Joined:
    Oct 30, 2009
    Posts:
    160
    I guess your object is being deleted because you have some destroying code on the OnDisable class. Maybe you could add some conditional code on it to avoid it being destroyed at its initialization. You could also build a Prefab and instantiate it with GameObject.Instantiate() function.
     
  3. SGDavid

    SGDavid

    Joined:
    Mar 17, 2010
    Posts:
    12
    I do not do anything in the OnDisable() that should destroy anything.
    I tried the prefab solution and get the same behaivor.

    Here is the Awake() and OnDisable()

    It always states "Set Inactive" in the console.
     
  4. Barbur

    Barbur

    Joined:
    Oct 30, 2009
    Posts:
    160
    Probably you should write DontDestroyOnLoad(this.gameobject) instead of DontDestroyOnLoad(this).
     
  5. onllm

    onllm

    Joined:
    Mar 4, 2011
    Posts:
    111
    i have the exact same problem how did u fix?
     
  6. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    716
    anybody find a fix for this
     
    LaserWzzrd likes this.
  7. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    This is really annoying on a headless server...
     
  8. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    Did anyone find a solution for this?
     
    MiguelAppStudio likes this.
  9. charmcrescini

    charmcrescini

    Joined:
    Sep 9, 2019
    Posts:
    18
    MiguelAppStudio likes this.
  10. MiguelAppStudio

    MiguelAppStudio

    Joined:
    Nov 17, 2020
    Posts:
    19
    Hello @charmcrescini
    First I apologize for bothering you and taking up your time.
    It's clear to me that it's been a long time since I posted this issue, but I'm going through the same thing now.
    I have reviewed your link, but I am not sure what I should do to solve it

    After so much time has passed,
    Do you remember how I solved this problem ?
    I hope you can help me, I am working on this problem for 3 days
    Thanks
     
    okeehl likes this.
  11. SangminLim

    SangminLim

    Joined:
    Jul 12, 2023
    Posts:
    1
    하하이용