Search Unity

Bug World Dispose Memory Leak!!!

Discussion in 'Entity Component System' started by lijianfeng, May 29, 2020.

  1. lijianfeng

    lijianfeng

    Joined:
    Sep 8, 2015
    Posts:
    54
    Code (CSharp):
    1.     void Test()
    2.     {
    3.         var world = new World("123");
    4.         var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, false);
    5.          DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
    6.         world.Dispose();
    7.         world = null;
    8.         systems = null;
    9.  
    10.         GC.Collect();
    11.         print(Profiler.usedHeapSizeLong);
    12.     }
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.        Test();
    17.     }
    When I run this code in editor ,standalone or server build, it looks like the World has some memory leak problem:mad::mad::mad::mad::mad::mad::mad::mad:
     
  2. JWittig

    JWittig

    Joined:
    Apr 5, 2020
    Posts:
    6
    Bump. I have got the same problem with entities/entities graphics 1.0.16.
    I am loading an addressable scene with objects that get transformed into entites on runtime. When unloading this addressable scene, there is a memory leak. Continuously loading/unloading the same scene results in increasing memory usage
     
  3. yinthewater

    yinthewater

    Joined:
    Jul 25, 2020
    Posts:
    15
    I'm not sure how you set up the World, we have run into an issue where the world leaks memory every frame update, the fix we found is to add this line: upload_2024-1-5_16-24-13.png