Memory Issues when using Siemens NX

Hello Unreal Community,

I’m working on a prototype for modeling CAD data in VR with the Unreal Engine.
I have managed to get my Unreal project to build with my CAD System Siemens NX, or rather the API NXOpen.

Overall the API works and I can call NXOpen functions.
But some operations cause crashes and my guess is that it has something to do with memory management.
I cant wrap my head around what exactly is happening.

For example I have code that creates a NX block that works fine.
Afterwards I’ll need a body object that is stored inside the block. The access also works, but when ‘bodies’ runs out of scope, it crashes.




    // 'block' gets created here

    if (block) {
        std::vector<NXOpen::Body*> bodies = block->GetBodies();
        if (bodies.size() > 0) {
            NXOpen::Body* body = bodies.front();
        }
    } // <-- this line crashes



If I understand the callstack (attached) correctly the error occurs when the object is deleted. But why can that be the problem?
Could it be that both Unreal and the NX third party lib try to manage the memory?

Has anyone a hint what could cause these crashed and even an idea how to solve it?
I’m happy to give more information if necessary.

Greetings,
LaRanaRica