Download

Trying to optimize loading times with soft reference lazy loading

Hi everyone,

I am struggling with optimizing loading time for my game, I recently tried using soft references to fix this but result was even worse…

I have 1x1km open world with around 15k actors loaded at start. Around 10k of those actors are destroyable physical objects - lets call them OBJECTS. They consist of one static mesh and the logic related to them - taking damage, hitting each other, initializing…

I tried to optimize creation of those OBJECTS - I create them without any data, empty static mesh ref in static mesh comp and light begin play logic. They only start with ID. Then I initialize them when player gets near enough - from data table i load the definition of this object by its ID - data table has some bools, floats etc and soft refs to static meshes. I then load that static mesh, do the whole initialization logic etc.

I added lots of code to the OBJECT to do that lazy initialization - i hoped it would cut out loading time of level because i would not need to load static mesh/texture etc at start, but later. In editor i have editor-only static mesh component with hard ref so i see how the object looks like on map, but this component is not in the packaged game, so I assume it is not loading anything because of it.

But all that effort resulted in even longer loading times, from 1:30 minutes on SSD to 1:50. I dont understand it, it looks like all that code i wrote for fancy lazy initialization which is not even running at start has additional impact on loading time, makes the objects heavier i guess. Memreport shows that objects got a bit bigger, but overall memory usage is lower about 10%, which looks like it really does not load that much at start and it makes sense to me in numbers considering what is optimized.

But I hardly understand memreport logs and I am just confused because clearly I am doing lots of work which does not make any sense. Anyone have an idea what may be wrong and where should i actually look for solution?

I attached parts of my memreports after and before “optimization”. I removed part with obj list - it only show that objects got a bit bigger after the change - but overall memory usage looks lower.