# How does the Unreal compiler handle references to container structs in memory?

**URL:** <https://forums.unrealengine.com/t/how-does-the-unreal-compiler-handle-references-to-container-structs-in-memory/463200>\
**Category:** Editor Scripting\
**Tags:** variables, data-structures, reference, container, memory-management, unreal-engine, question\
**Created:** [April 2, 2020, 11:08am UTC](https://forums.unrealengine.com/t/how-does-the-unreal-compiler-handle-references-to-container-structs-in-memory/463200 "2020-04-02T11:08:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goonix\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Goonix\_1](https://forums.unrealengine.com/u/Goonix_1)\
**Post date:** [April 2, 2020, 11:08am UTC](https://forums.unrealengine.com/t/how-does-the-unreal-compiler-handle-references-to-container-structs-in-memory/463200/1 "2020-04-02T11:08:37Z")

</div>

I know this is a broad one, but let me explain.

I’ve been trying to clean up my code and make it easier to write. I thought I’d use some references to some bigger structs I’ve been using.

In my code I have a reference variable to a parent struct, and a reference to a child of that struct. The parent and children are both in TMaps.

I was seeing errors in my code which I realised have resulted, seemingly, from the fact that when I make some changes to the child, they are not reflected properly in the parent.

I am not sure whether the data is being moved or the referencing is actually making a copy or preventing other references from editing the data being referenced. The odd thing is that some data does stick.

Does anyone have experience using references with Unreal cpp and/or is this a known bad practice with reference variables? My reading has turned up nothing so far.

Edit: To satisfy my own curiosity on the memory question, I recreated the child reference after I edited the containing map and a sibling map. The behaviour is the same. I then edited the same value using a path from the parent and it stuck.
