Skip to main content

Chunked Loading (Anti-OOM)

When you load hundreds or thousands of assets simultaneously, the streaming system pulls them all into RAM at once, which can cause a large RAM spike or even an out-of-memory crash on lower-end hardware.

Chunked loading solves this by splitting the asset list into smaller batches (chunks) and loading them sequentially. The next chunk starts only after the previous one has finished.

Enabling chunks

Set ChunkSize in FAsyncKitLoadParams to the number of assets per batch:

Params.ChunkSize = 50

ChunkSize = 0 (default) disables chunking and loads everything at once.

Example

Loading 200 meshes with ChunkSize = 50 results in 4 sequential loads:

[Chunk 1: meshes 1–50]  ──▶ loaded
[Chunk 2: meshes 51–100] ──▶ loaded
[Chunk 3: meshes 101–150] ──▶ loaded
[Chunk 4: meshes 151–200] ──▶ loaded
──▶ On Loaded fires with all 200 assets

The On Loaded callback and On Completed pins fire only once — after all chunks are done — and receive the complete array of loaded assets.

Progress with chunks

Use Load Assets With Progress (or the AsyncKit Load With Progress node). Progress is reported after each chunk:

After chunk 1: Progress = 0.25, Loaded Count = 50
After chunk 2: Progress = 0.50, Loaded Count = 100
After chunk 3: Progress = 0.75, Loaded Count = 150
After chunk 4: Progress = 1.00, Loaded Count = 200

Choosing a chunk size

ScenarioRecommended ChunkSize
Small assets (textures, sounds < 1 MB each)100–200
Medium assets (meshes, materials)20–50
Large assets (level subsets, large textures)5–20
Unknown / safety default50

Monitor memory usage in-session with Stat Memory to tune for your project.

tip

Combining ChunkSize with bRetainAfterLoad = false lets the GC reclaim memory from earlier chunks while later chunks are loading, keeping the peak memory footprint minimal.