How to dynamically allocate memory, self memory management

Hello,

MY QUESTION:

How to dynamically allocate memory for UE4 container i.e TArray,
and UCLASS, and USTRUCT? without troubling GC and allow me to manage my own memory.

Where is the best location of free those memory, I am currently override the BeginDestroy();

PS: USTRUCT seems can work with new.

MY intention:

I am making a inventory system, so I build a UCLASS() APlayerInventory from AActor.

Since UPROPERTY does not allow TArray* and FStruct*, and my inventory will contain tons of information. So I am considering using pointers and running my own dynamic allocated memory.

Therefore, I use transitional c++ approach new in constructor, and no compile error and editor crash. I predicatively know it wont work TT

APlayableCharacter::APlayableCharacter()
{
	Inventory = new APlayerInventory();
}


APlayerInventory::APlayerInventory()
{  
	// dynamically allocated a TArray to store our inventory info
	InventoryItemInfos = new TArray<FInteractableItemInfo*>();
	InventoryItemInfos->Reserve(inventorySize);

}

where FInteractableItemInfo is USTRUCT, that i will use to pass infomation between player controller and UI

Here are the crash reporter message:

Fatal error: [File:D:\Build++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 2538]
UObject() constructor called but it’s not the object that’s currently being constructed with NewObject. Maybe you trying to construct it on the stack which is not supported.

UE4Editor_MannequinVsMaximo_852!APlayerInventory::APlayerInventory() [e:\unreal4\unreal project\mannequinvsmaximo\source\mannequinvsmaximo\playerinventory.cpp:10]
UE4Editor_MannequinVsMaximo_852!APlayableCharacter::APlayableCharacter() [e:\unreal4\unreal project\mannequinvsmaximo\source\mannequinvsmaximo\playablecharacter.cpp:35]
UE4Editor_MannequinVsMaximo_852!InternalConstructor()

FINAL PS:
If anyone knows how to detect memory leak, please enlighten me. I am planing to make some memory trace function.

FINAL FINAL PS:

THANKS IN ADVANCED!!!

Update:

I use

	Inventory = NewObject<APlayerInventory>(this);

instead. and Get other error message from crash reporter.
Fatal error: [File:D:\Build++UE4+Release-4.15+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 3301]
NewObject with empty name can’t be used to create default subobjects (inside of UObject derived class constructor) as it produces inconsistent object names. Use ObjectInitializer.CreateDefaultSuobject<> instead.

Anytime you use UCLASS, USTRUCT, UENUM, it is going to be a part of UE4’s memory management system as that is what these macros will do.

As for managing your own memory, I would suggest not using any UE4 macro as I am still not 100% on what each will do, only that they are setup for memory management. If you create a class that doesn’t extend anything from UE4, such as UObject, you are then probably expected to manage any memory reserved for those types.

It is kind of an odd thing to try and manage in the game frame work because memory management is very much a part of it and meant to be used.