I’m running a project that spawns a bunch of static meshes of cars. Each of these cars has a dynamic material used for paint (from the Automotive materials pack) so they can all have random paint colors.
Now, when I spawn all the cars in a level blueprint, then let the level run then completely reload the level (with a call to the Load Level node) everything works fine. I can run this process as long as I want.
However, to get a performance increase (and increase the size of the level) I stopped reloading the level when I want different car meshes spawned and instead call the Get All Actors of Class node, loop through all the cars and destroy them. I then call the process that respawns all the cars. This also works, but after about 10-15 cycles of this, the project crashes, popping up a window that says “Out of video memory trying to allocate a texture!”
Do I need to explicitly delete all the dynamic materials created when spawning the cars somehow? This whole thing feels like garbage isn’t being collected if I don’t reload the full level (which I’d rather not have to do).
Any help will be appreciated, thanks!