How-To: Reduce memory usage

A common question developers have is, “Is there anything I can do to reduce memory usage?”

The single most effective thing a developer can do to reduce memory use is to ensure you are structuring your scene graph efficiently. Compared to a pure graphics API such as OpenGL, HOOPS Visualize is a “heavyweight” system because it needs to organize and retain information about the graphics it is displaying - segments, attributes, graphical primitives like shells, bookkeeping data for normals, face lists, and much more. For comparison, an OpenGL-only application usually has a minimal set of data structures.

For this reason, proper scene graph use is essential. Memory use could perhaps be decreased by reducing the number of segments that are created (for example, by merging shells into fewer segments). If there is a single shell per face in a body, then merging those shells to have only one shell per body could reduce memory quite a bit. Using one shell for a cube is much better than using one shell for each face of a cube. Geometry with common attributes are usually good candidates to combine into a smaller number of shells or segments.

Loading the model into the HOOPS Demo Viewer and browsing the segment tree would give some information on the number of segments, shells, etc. Loading the model into the HOOPS Partviewer (included in the HOOPS-3DF package), would also allow you to do some optimizations, such as reducing the number of segments and merging shells. Then, you could turn on the “Show statistics” option to see if the “in-use” or “allocated” memory has been reduced.

Everything may be already correct. The scene graph is reasonably well organized, HOOPS is allocating and using memory correctly, and HV is simply going to use more memory than a similar application because it is a retained-mode graphics system.

For more information on memory management, including handling out-of-memory situations, please see this article in the HOOPS Visualize Programming Guide:

https://docs.techsoft3d.com/hps/latest/prog_guide/0704_memory_management.html

The following article also has more details about proper segment organization:

https://docs.techsoft3d.com/hps/latest/prog_guide/0703_performance_considerations.html