In principle that should just work, so some more information would be required.
Please always provide the following system configuration information when asking about OptiX issues:
OS version, installed GPU(s), VRAM amount, display driver version, OptiX (major.minor.micro) version, CUDA toolkit version (major.minor) used to generate the input PTX, host compiler version.
What kind of crash?
What’s the call stack?
Does this happen with any of the OptiX SDK examples? (Esp. these: optixDynamicGeometry, optixGeometryTriangles, optixInstancing, optixMotionBlur, optixPrimitiveIndexOffsets.)
Note that the C++ wrappers in OptiX 1 - 6 do not reference count and manage the lifetime of the underlying OptiX objects. If you want to delete the underlying objects you must call the destroy()
function explicitly, which effectively means you either need to query the resp. C++ objects from your hierarchy, or (faster) track all your C++ objects in a shadow graph, or add the ref-counting to the C++ wrappers.
https://forums.developer.nvidia.com/t/geometrytriangles-setvertices-and-setbuffer-vertex-buffer/82925/2
https://forums.developer.nvidia.com/t/optix-garbage-collection/158116/2
If you’re starting new projects with OptiX, it’s recommended to use OptiX 7.x versions (best 7.3), which use a much more modern, explicit, flexible, and faster API than previous OptiX versions.