Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Memory management of spawning more random prefabs than can stay in memory at once.

Discussion in 'Graphics for ECS' started by goodnewsjimdotcom, Oct 19, 2022.

  1. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    342
    Hello,

    I have a large variety of random spawnable enemies and I do not want them loaded in memory unless they spawned and are active.

    What is the most reasonable way of doing this?

    The way I'm doing it now is:
    1) array of disabled ECS Entities for the most common spawnables like lasers, common enemies. I use this disabled enity list to rapid instantiate entities.

    2) For the sake of arguing I'll do this part wrong and someone to correct it: an Addrssables group with 2000 prefab GameObjects.

    3) Since I do not believe you can instantiate an entity directly from an addressable group and I don't mind if the spawn took 3000 ms aka 3 seconds, then taking a GameObject into memory long enough to spawn to enity. I will then dispose of this adressable from memory.


    Is that acceptable and cromulent? How should I be doing it? I have a very massive game I want to maintain for years and become very super massive aka Terabytes on disk. I want to make sure my foundational memory management is fine.

    Bonus: I could get fancy by leaving Entities spawned into a disabled entity buffer like I successfully use in #1, but I'd have to know the memory limits of the machine and how much used.

    On .51 waiting for 1 to get stable before porting