Announcement

Collapse
No announcement yet.

[Solved] Force garbage collection on manually loaded world.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Solved] Force garbage collection on manually loaded world.

    Hey,
    I'm creating plugin that does offline generation on maps.

    So I'm loading world, doing some work on it, mainly placing assets, and then I want to save it, close it, and open another one.

    Problem is that those worlds don't get garbage collected and I run out of memory after few.

    I assumed that calling
    Code:
    World->DestroyWorld()
    followed by
    Code:
    CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS)
    would be enough. It wasn't.

    I tried marking world and package from which it's loaded with
    Code:
    MarkPendingKill()
    I cleared them standalone flags by hand
    Code:
    ClearFlags(RF_Standalone)
    I even tried calling
    Code:
    RemoveFromRoot()
    and
    Code:
    ConditionalBeginDestory()
    on them and all objects that have them as outer collected from
    Code:
    GetObjectsWithOuter()
    I think I'm missing something. It surely is possible as I can load level and unload it in editor UI and world is properly cleaned(I check with memreport)

    #2
    Hi, miniu, and welcome to the forums!

    Please excuse me for questions that may seem stupid, but:

    1) Are you sure that there are no references left to those worlds and/or any actors placed on them? Because if there are they will not be GC’ed.

    2) Are you sure the OOM you are getting is related to those worlds being left in memory and not to some other memory that might have been leaked during the generation process?
    Realistic Atmosphere 2.0 | YouTube | Forum | Marketplace

    Comment


      #3
      Thanks for welcome

      @1 I assume that this is a problem probably. I just can't find those references. This or I'm removing them incorrectly.
      I'm doing same generation on loaded levels though and if I use UI to unload them I don't get objects left over. So it seems to me that it's related to either how I create these levels or how I unload them.

      @2 Yes, I look at "memreport --full" and I see that the memory that is "leaked" are Hierarchical Instanced Meshes that I created, all of them from all the worlds I created and thought that I destroyed are still there. I also see that World objects count is same as number of worlds that I loaded.

      [Edit]
      Found FReferenceFinder and "obj refs" command. I'll try to use it to find who references my levels.

      [Edit]
      Turns out it was validator checking if my save has gone properly.

      I did save and unload on level at the same frame, next frame validator was checking if everything saved properly world was missing so it just loaded it again.
      Last edited by miniu; 02-13-2020, 04:46 AM.

      Comment

      Working...
      X