What is the proper way to destroy geometry?

Should I destroy GeometryGroup and that’s it, or should I destroy Buffers, Geometry, GeometryInstance
and GeometryTriangles that GeometryGroup contains?

That looks like a noob question, but I cannot find confirmation that destructors clears components.

I have:

while (geometry_group->getChildCount() > 0)
    {
        auto gi = geometry_group->getChild(0);

        gi["vertex_buffer"]->getBuffer()->destroy();
        gi["normal_buffer"]->getBuffer()->destroy();
        gi["index_buffer"]->getBuffer()->destroy();
        gi["texcoord_buffer"]->getBuffer()->destroy();
        gi["material_buffer"]->getBuffer()->destroy();

        gi->getGeometryTriangles()->destroy();

        geometry_group->removeChild(0);

        gi->destroy();
    }
    geometry_group->destroy();
    geometry_group = context->createGeometryGroup();

Using Optix 6.5, drivers: 496.76

Right, with the C++ wrappers inside the old OptiX API, you need to explicitly call destroy() to get rid of the underlying OptiX objects. Exactly the same as if you used the actual C API entry point functions.
https://forums.developer.nvidia.com/t/optix-garbage-collection/158116/2

The C++ wrappers are headers inside the OptiX SDK. You can step through them with your debugger to see what is actually happening.

(Inside the new OptiX 7 API all this is done with native CUDA allocations and you define where the necessary CUdeviceptrs come from, e.g. from individual allocations (slower) or by using some blocks of memory in some arena allocator.)

Yes, I must move to the Optix 7.

Thank you, I appreciate the link and your help!

Also I think I missed

gi->destroy();

as the last call in the loop… I’ve edited the post so it’s complete now.