# Optimization reference

This page is intended as a reference collection of optimization tricks that can be used to speed up JME3 applications.

## Maintain low Geometry count

The more Geometry objects are added to the scene, the harder it gets to handle them in a speedy fashion. The reson for this is, that for every object a render command must be done, here is a bottleneck betwenn the CPU and the Graficcard.

Possible optimization techniques

- Use GeometryBatchFactory.optimize(node) to merge the meshes of the geometries contained in the given node into fewer batches (based on common Material used).

Side-effects

- Using GeometryBatchFactory merges individual Geometries into a single mesh. Thereby it becomes hard to apply specific Materials or to remove a single Geometry. Therefore it should be used for static Geometry only that does not require frequent changes or individual materials/texturing.
- Using Texture atlases might be a way to provide a limited individual texturing.

## Avoid creating new objects

When you use math operations like vectorA.mult(vectorB); new objects are created that have to be garbage collected when you don't use them anymore. Check your math operations for opportunities to use the local version of the math operations, e.g. vectorA.multLocal(vectorB). This way the result is stored in vectorA and no new object needs to be created.

performance

view online version