Search Unity

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