Referencing actors in multiple BP: performance / memory issue? (simple diagram provided)

Hello,
Let’s examine this basic diagram for an RTS game as an example:

(link if the picture does not show : Excalidraw | Hand-drawn look & feel • Collaborative • Secure )

Multiple BP_Buildings are constructed on the map, meaning all their variables, textures, functions, and other elements are already loaded.

All these BP_Buildings on the map are also stored in an array within the BP_GameMode. This approach makes it potentially easier to save their states, positions, and variables in a file save, invoked by the game instance (GI).

Additionally, there is a specific building, a Town Center, with an Influence Zone, where all buildings within the radius are “linked” to the TC. Consequently, any action performed on the TC can also affect all buildings within the radius.

Now, I am curious: since the buildings are already present in the game and on the map, does referencing them in an array in the GM double the amount of memory they consume? Furthermore, does adding some of them in the BP_TC actually triple their memory usage?

Is this approach considered a bad or good practice in terms of memory management and performance?

No.

References are not copies of the actors. References are just Pointers.
A pointer is an address in memory. A reference is just a memory address to
find and reach an actor. Not a full copy of that actor so you can freely
reference anything anywhere :slight_smile:

1 Like

Thank you for your answer. It’s a relief, then. I was a bit unsecured about making a lot of those arrays. Like an array for all the military buildings, another one for storage buildings, another one for production buildings (and now I can make a structure with all of them), and then why not more arrays for new types of units, etc.
It’ll be way easier and handful to use.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.