Search Unity

Out of Memory Building Content

Discussion in 'Addressables' started by chris_hellsten, Aug 19, 2019.

  1. chris_hellsten

    chris_hellsten

    Joined:
    May 5, 2014
    Posts:
    4
    Every time I try to build content for my project I get out-of-memory and crash, Unity 2019.2.0f1 & Addressables@1.1.7.

    I have approximately 5GB of models (FBX) in my project, not all can be loaded into memory at once. I am streaming based on player proximity at run-time and this was working on a previous slightly smaller batch of models. To facilitate the streaming the models are packed separately, so I have a very large number of asset bundles being generated (~3000).

    My developer machine has 16GB of RAM but I would have hoped it would be enough to do a successful build. The memory management in the build asset bundles stage is actually very efficient, but when we reach GenerateLocationListsTask.Run, memory spikes up to maximum (virtual memory allocation can't cope either) and the process crashes. The crash always occurs in the call to CreateResourceLocationData, possibly related to the large amount of data generated in the dictionaries and lists being created in the surrounding loops.

    The build succeeds if I only build 1 asset group at a time, but each time I perform a build, the catalogue replaces the entries from the previous build. Is there a way I can work-around these memory limitations by additively building my assets into the catalogue instead of replacing it when I do a new build?

    The log crashes with:
    DynamicHeapAllocator out of memory - Could not get memory for large allocation 4804516!
    Could not allocate memory: System out of memory!
    Trying to allocate: 4804516B with 32 alignment. MemoryLabel: VertexData
    Allocation happened at: Line:171 in C:\buildslave\unity\build\Runtime/Graphics/Mesh/VertexData.cpp

    The reference to VertexData.cpp leads me to believe the assets are being loaded into memory in this step? Is this necessary?
     
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    639
    We had exactly that in Addressables 0.5.3 when building for Windows. Building for iOS worked fine. We have now rebuilt out catalogue from scratch for the later versions of addressables and it's stopped happening, so I am not entirely certain what was causing it.
     
  3. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    913
    this may be impossible due to the size of your project, but if you could file a bug against unity with your repro case, that would be a huge help. We'd love to track this down, but can't seem to create a synthetic test that triggers it.
     
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    639
    When I have a little bit of time, I can try to instrument the build step to find what asset triggers it and see if I can isolate it into a repro. From what I remember, the memory allocation it attempts is ridiculous, many GiB.
     
  5. chris_hellsten

    chris_hellsten

    Joined:
    May 5, 2014
    Posts:
    4
    I did put together a simple repro project with nothing but Addressables and a (big) bunch of FBX files, but I tried to submit the bug-report 4 times, and after uploading I get:
    upload_2019-8-20_21-55-40.png
    Time to report a bug on the bug reporter >.<
     
  6. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    639
    Sounds like a transient server issue to me, I'd try again in a couple of hours and see what happens. If that fails, I'm sure you can ask the Unity guys for a Google Drive account to upload the repro project to instead.
     
    unity_bill likes this.
  7. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    639
    Yikes. I’m currently staring at a build that has allocated 65GB of RAM... so far!