How does memory allocation of Actors works?

Hello,

We (our small company) are planning to make our next game with UE4. I’m the dev and I’m not that an expert when it comes to C++, haven’t used this language for years. I’m also quite new to Unreal.

My question is about memory management in UE4 :

  1. Are there any tools to watch memory allocation/consumption while debugging? (tried googling a bit, not much, didnt find yet)

  2. Let’s say most of our NPC/enemies will be spawn at runtime (because of partial procedural design). Since I don’t really know how else to do it in UE, I’m thinking about having either a singleton or static var (doesn’t matter) in a class to reference all possible NPC , like this (example for 1 npc type, lets say a killable orc, most npc are juste killable enemies in our game) :
    TSubclassOf<class ACharacter> CharacterAI_BPClass;//.h

in cpp constructor :
static ConstructorHelpers::FObjectFinder<UBlueprint> lBlueprint(TEXT(“Blueprint’/Game/ThirdPersonBP/Blueprints/CharacterAI.CharacterAI’”)); // ‘/Game/ThirdPersonBP/Blueprints/CharacterAI.CharacterAI’
if (lBlueprint.Object) {
CharacterAI_BPClass = (UClass*)lBlueprint.Object->GeneratedClass;
}

So I’m able to spawn whatever NPC type by code in any part of the game. Works fine by the way.

Question is, how much memory does this use while there is no instance of said BP class instanciated? Does it just create a reference to where it should find the data on disk (I hope) or does it also load to memory all the meshes/textures found in the components of said BP class (which would prove this design horrible)?
Another question : ofc when one instance is spawned, all data is loaded, but is it well freed when the last instance of said type is destroyed?
Another other question : UE4 supports instanciation (is the term batch?) of same meshes/texture without duplicating it in memory right? If I have 100 instance of the same orc at one time, I don’t get 100 clones of the textures/meshes in memory right?

The Game will be a lot level based/area based so we really want to avoid having all possible npcs data loaded into memory when there are just 5 different types of enemies in one level.
Also, is the answer the same on all platform? (iOS, Android, PC exe at least).

Regards,

Still haven’t found an answer to what is loaded in memory when creating references to blueprints classes.
Same goes for other questions like what happens when many instance of the same blueprint class and when last instance is destroyed.

Any help appreciated :slight_smile:

EDIT : should I move this to C++ subforum?