SetVectorParameterValue Crash (FMallocTBB::Realloc)

Hi,
I’m having an issue with my code, dealing with Material Instance Dynamic. Here is what I do in my Character C++ class:

In the constructor (where ColourationBrush.ColourationBrush is a Material):



static ConstructorHelpers::FObjectFinder<UMaterialInterface> MaterialBrush(TEXT("Material'/Game/3D/ColourationBrush.ColourationBrush'"));

if (MaterialBrush.Object != NULL)
    ColourationBrush = MaterialBrush.Object;

In my BeginPlay:



Brush = UMaterialInstanceDynamic::Create(ColourationBrush, NULL);

In the Tick:



Brush->SetVectorParameterValue(FName("locationWS"), FLinearColor(1, 1, 1, 1));

In my .h, all in public, for the type purposes:



UMaterialInterface* ColourationBrush;
UMaterialInstanceDynamic* Brush;

And finally, here is my call stack:



[2016.11.12-02.19.48:254] 33]LogMac: === Critical error: ===
SIGSEGV: invalid attempt to access memory at address 0x0

[2016.11.12-02.19.48:254] 33]LogMac: scalable_msize() Address = 0x56539ab  (filename not found) [in UE4Editor-Core.dylib]
FMallocTBB::Realloc(void*, unsigned long, unsigned int) Address = 0x5727848  (filename not found) [in UE4Editor-Core.dylib]
FMemory::Realloc(void*, unsigned long, unsigned int) Address = 0x5733092  (filename not found) [in UE4Editor-Core.dylib]
TArray<FInterpCurvePoint<FVector>, FDefaultAllocator>::ResizeGrow(int) Address = 0x839d779  (filename not found) [in UE4Editor-Engine.dylib]
void* operator new<FVectorParameterValue, FDefaultAllocator>(unsigned long, TArray<FVectorParameterValue, FDefaultAllocator>&) Address = 0x8ed8ae0  (filename not found) [in UE4Editor-Engine.dylib]
UMaterialInstance::SetVectorParameterValueInternal(FName, FLinearColor) Address = 0x8ee057f  (filename not found) [in UE4Editor-Engine.dylib]
AHanaV2::Tick(float) Address = 0xcfda4dc0 (filename not found) [in UE4Editor-hana-7917.dylib]

If anyone had an idea of what causes the crash, that would be really appreciated. It happens all the time around ~1 minute of play, never before. It is really constant in the time it crashes.
Thank you very much!

We resolved this. For future people who may have the same issue, just do this:


UPROPERTY() UMaterialInstanceDynamic* Brush;

If there is no UPROPERTY(), the engine garbage collector does not know that the object exist!