I am getting a sudden rise in RAM usage!



In Corona Renderer 3 and newer, the "System is running low on RAM" error message will display a breakdown of various rendering components and their RAM usage. This provides the user with information what exactly should be optimized to lower the 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 Renderer, 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:


Note: in Corona Renderer 3 and newer, there is a new autobump feature, which greatly reduces the RAM usage with no visible quality loss. The below tips were meant for older versions of Corona Renderer, where autobump was not used, but they may still help you get even lower RAM usage:

  • 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.
  • If the scene was created in an earlier version of Corona, you will be asked to switch to a "new displacement behavior" when loading it. Make sure you do as this will activate the new displacement algorithm which uses significantly less RAM. More information can be found here: what is the autobump feature?

  • Additionally, you may use the CoronaDisplacementMod modifier to override the quality of the displacement on various objects. If this modifier is used on an object, the displacement settings in the Render Setup > Performance dialog will be ignored for this specific object, and instead the settings from the modifier will be used. This is useful to define a "level of detail" for objects which are closer or farther away from the camera, or closer to the center or the borders of the frame. 



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

Currently 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 possible number.
  • 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 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