Efficient Bulk Updating - xsquawkbox/xplanemp2 GitHub Wiki

As xplanemp2 uses a list of updates pushed through a single API call, rather than the callback system it had previously, there's a few things to watch out for which can be performance killers.

Do not dynamically allocate/destroy an array/vector every frame

The allocator will hurt your performance significantly or create heap fragmentation under heavy load which may cause you trouble later.

The correct solution is to allocate it once, oversized, and only resize it when you absolutely have to.

Use update holes rather than rewriting the entire update list

In order to let you leave holes in the update list, you can provide a null (0) XPMPPlaneID and that slot will be ignored.

Rather than rebuilding the entire update list every frame, if your data is static in memory, you can just blank out the holes when a plane is to be dropped, and then reuse those holes first.