edited October 21 in ORK Support
Hi,
I added a lot of images to my project, then build and run on my Android phone.
It crashes on startup. After check the Monitors in AndroidStudio, the memory usage is up to 1 GB.
Then I check the profiler in Unity, It seems like that the Unity load most of my assets to memory, but in my scene there just one background image and a few buttons. Most of the textures(not used in current scene but loaded to memory) are referenced by ORK.
Is this normal?

All of the assets/textures are NOT in the Resources folder.

Image and video hosting by TinyPic
Post edited by bitmore on
  • edited October 21
    Here is my new test:
    I created a new clean project, didn't import ORK at the first, but import some textures. Set one of the images as scene background. Everything works fine, the profiler shows only one image was loaded.
    Image and video hosting by TinyPic

    Then I import ORK into the project, and set one icon as a combatant's avatar in ORK Editor. After that I didn't do anything. No ORK Starter in the scene, didn't spawn the combatant, didn't use the icon in the scene, the icon is totally UNUSED unless set as avatar in ORK Editor.
    After running the project, the profiler shows that icon was loaded. See the image below.
    Image and video hosting by TinyPic

    My ORK version is 2.17.0, I tested this both in Unity 2017.1.0f3 and Unity 2018.2.
    Post edited by bitmore on
  • In case you need the test project, I uploaded it to the Dropbox, here is the download link:
    https://www.dropbox.com/s/ihqcngb7kvji2i4/TestMemoryUsage.zip?dl=0
  • From Best Practices: Objects, Assets, and Serialization:
    When an Object is loaded, Unity tries to resolve any references by translating each reference's File GUID and Local ID into an Instance ID. An Object will be loaded on-demand the first time its Instance ID is dereferenced if two criteria are true:

    The Instance ID references an Object that is not currently loaded

    The Instance ID has a valid File GUID and Local ID registered in the cache

    This generally occurs very shortly after the reference itself is loaded and resolved.
    So when the ORKProject.asset is loaded, all object references are resolved and loaded at the same time. There isn't anything that you (personally) can do about it. So when that database is loaded, it also loads all images, prefabs, audio files, etc referenced anywhere in it.

    I can't find the post, but @gamingislove refers to this as a primary reason for moving to a new database structure for ORK v3 where each data item is stored as an individual .assset file (in other words, each data item class inherits from ScriptableObject).

    Please correct me if I'm wrong, GiL.
  • Yeah ... it's pretty much as @Keldryn said. This is a general issue with how Unity handles this stuff, as it loads everything that is connected with an asset when that asset is loaded.

    I hope to change this with the overall data structure changes coming in ORK 3 in the future. The only other way would be to go back to using the Resources folder as it was done in ORK 1, although Unity discourages from using that method :)
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • @gamingislove - Have you looked into the Unity Addressable Asset System yet?
    AssetReference - An object that operates like a direct reference, but with deferred initialization (for example, for lazy loading). The AssetReference stores the GUID as an addressable that you can load on-demand.

    Asynchronous Loading - allows the location of the Asset and dependencies (for example, local, remote and generated) to change throughout the course of your development without changing the game code. Async Loading is foundational to the Addressable Asset System.
    More on its forum thread.

    It's still at a "preview" state, and it will require Unity 2018.2 and up (well, it's distributed via the Package Manager; I haven't tried copying the code files into an older Unity version to see if they work there).
  • I've heard of it but didn't look into it yet - as it's still in preview and potentially not available on pre 2018 Unity versions it's currently not really an option :)
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.