# C++ Variable reference slow

**URL:** <https://forums.unrealengine.com/t/c-variable-reference-slow/331473>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** UE4-8, UE4-9, unreal-engine, Performance, bug-report, CPP, question\
**Created:** [September 8, 2015, 5:28pm UTC](https://forums.unrealengine.com/t/c-variable-reference-slow/331473 "2015-09-08T17:28:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DekanTrue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DekanTrue](https://forums.unrealengine.com/u/DekanTrue)\
**Post date:** [September 8, 2015, 5:28pm UTC](https://forums.unrealengine.com/t/c-variable-reference-slow/331473/1 "2015-09-08T17:28:04Z")

</div>

Hi,

I don’t know if this is a bug or working as intended. The scenario is this. I have an array in blueprint, that I pass to c++ as a reference. It is an array of structs (a lot), and in 4.7.5 there are no spikes in the unit graph. But if I update to 4.8 or 4.9, there are big spikes in the graph, event though the function doesn’t do anything.

I have created a test project to illustrate what I am saying. You can generate and build the solution, test, then update to 4.9 and see the difference. Note: The funciton runs on “T”.

> **[GitHub - kimFrost/TestCReferencePerf: TestCReferencePerf](https://github.com/kimFrost/TestCReferencePerf)**
>
> TestCReferencePerf. Contribute to kimFrost/TestCReferencePerf development by creating an account on GitHub.

The test function can be found in the level blueprint and in a c++ function library.

I have previously posted this as a question, but no one could supply and answer:

> **[C++ TArray Reference performance slow in 4.8 + 4.9](https://forums.unrealengine.com/questions/296145/c-tarray-reference-performance-slow-in-48-49.html)**
>
> I am having a performance issue with a TArray of structs, after upgrading from 4.7.5 to 4.8.3. I'm passing a the reference to the array to a function in a function library, which was working and performing fine in 4.7, but in 4.8 and 4.9, there is...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [September 8, 2015, 7:16pm UTC](https://forums.unrealengine.com/t/c-variable-reference-slow/331473/2 "2015-09-08T19:16:28Z")

</div>

Hey -

I was able to test the sample project you included and have submitted a report (UE-20865) for investigation.

Cheers
