I am getting a sudden rise in RAM usage!


Sharp, sudden rise in memory usage may result in incorrect rendering, error messages popping up, flickering windows, white squares appearing in the UI, general system slowdown, and even crashes. It can be caused by numerous things, and some of them include:



1. Displacement

In Corona, any mesh with a displaced material will be subdivided based on:

  • The complexity of the displacement texture
  • The quality settings under Render Setup > Performance > Displacement
  • Rendering resolution


If the displacement texture is very detailed, if the displacement quality is set to very high, or if the output resolution is very high, this may result in running out of RAM.


Solutions:

  • Do not use overly detailed displacement maps. Using displacement for producing fine details usually requires increasing displacement quality, which in turn may lead to running out of RAM. It is better to use displacement for bigger features of the material, and bump for the smaller details. Example: when rendering a brick wall, use displacement to obtain the general shape of bricks only, and use bump maps to simulate smaller details such as cracks or other imperfections.
  • Optimize the displacement texture by either blurring it, or clipping the brightest and darkest areas. This will greatly reduce the number of subdivisions required to displace the mesh. (see: https://corona-renderer.com/forum/index.php/topic,9728.0.html )
  • Avoid using overly detailed displacement maps on very high numbers of objects (e.g. on scattered trees forming a forest)
  • Avoid using overly detailed displacement maps in materials which cover large areas in the scene (e.g. floors, walls)
  • Try lowering displacement quality by increasing its screen size and observe whether the result is acceptable - the default value of 2px usually provides good quality, but when rendering in higher resolution, it can be increased to 4, 8, and often even more.



2. High-poly objects with Corona Light Mtl applied, scattered or otherwise heavily instanced (duplicated) throughout the scene

Currently (Corona 1.5.2) such objects cannot be properly instanced, which results in storing every single one of them separately in the memory. Using too many, or too detailed objects with the Corona Light Mtl applied may result in running out of RAM.


Solutions:

  • Reduce the number of polygons on the duplicated object
  • Reduce the total number of instances
  • Use Corona Mtl with self illumination enabled instead of the Corona Light Mtl - only if possible! For more information, see: Should I use Corona Light Mtl or Self Illumination?
  • When creating many lights (e.g. a factory hall with lots of ceiling lights) - apply a material with self illumination or Corona Light Mtl with "emit light" option disabled for the directly visible part (e.g. light bulb, or filament of a light bulb), and add separate, simple geometry to generate light. This can be a simple rectangle placed below the ceiling.



3. Render Elements

Each render element requires additional memory to be computed. The RAM usage increases with the resolution of the rendered image, and with the number of the render elements added.


Solutions:

  • If possible, avoid using render elements when rendering high-resolution images, or reduce them to the lowest number possible
  • If possible, avoid using denoising when rendering high-resolution images. Each denoised render element counts twice - it stores data for the denoised, and non-denoised version.
  • Optimize LightMix whenever possible - for example instead of creating 10 LightSelect elements for each light on a chandelier, group the lights, and create one LightSelect element controlling all of them
  • If a light does not need to be controlled individually using the LightMix, it can be left unassigned to any LightSelect element - in such case it will be automatically included into the "Rest (unassigned)" category, which counts as one render element only



4. Instancing (duplicating) animated objects

Currently (Corona 1.5.2) there is a limitation which makes it impossible to instance animated objects.



See also:

My system freezes when I start rendering!

"System is running low on RAM" error message