JPH_OVERRIDE_NEW_DELETE crash When Creating Classes With "new" keyword #1858
-
|
This one is super confusing. I have a global subsystem that uses the "new" keyword often I get no asserts. However, when I use the new keyword (this happens with multiple Jolt classes) from a component class I get a crash within the macro in the title. This is the code I'm calling from my component that causes the crash. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
So I've just done a simple test and it seems that you need to allocate memory per class that will create Jolt classes. I'm not sure if this is the right approach but I was able to avoid the crash that was happening. |
Beta Was this translation helpful? Give feedback.
I would call this function as early as possible in your
mainfunction, but if that's not possible it's not a problem to call it multiple times.Since you don't seem to want a custom memory allocator anyway, you can also recompile Jolt with
JPH_DISABLE_CUSTOM_ALLOCATORdefined to remove the need to callRegisterDefaultAllocator. In this caseJPH_OVERRIDE_NEW_DELETEdefines to nothing.See:
JoltPhysics/Jolt/Core/Memory.h
Lines 70 to 81 in 65f5c16