UE5 Variable is optimized away and not available when debugging

In this tutorial, we cover a debugging scenario where you will get the optimized variable message in the visual studio debugger when trying to watch variables. This hinders the debugging process as the developer can not see the variables he needs to troubleshoot.

Temporarily Turn Optimizations Off

Code optimizations are great because they speed up your code but the trade-off is less debugging information. To disable code optimizations for unreal engine code you need to turn them off at the module level. We do this in the build.cs


Go to your module’s build.cs and add this line:


OptimizeCode = CodeOptimization.Never;


This will disable code optimization for that module and you should be able to see all variables when debugging code in that module. Remember to comment out or remove the line when publishing or when done debugging.


Welcome to our audio and rhythm plugins collection! With MidiEngine, you can easily import MIDI files and use midi events to create engaging rhythm gameplay or enhance your videos.


Plugin that helps add UMG Widgets to Level Sequences for Text Layers, Movie Titles, 2D layers and more… directly within sequencer. Cross platform.


Let your end users Split And Resize The UI at runtime. Perfect for both games and Applications.

Consider investing in some of our plugins. They might save you some time.  Also helps supports these tutorials.

Instantly get access to our plugins like Blender Curves Importer and UMG Cinematics and more when  you support us on Patreon!

 Join Us On Discord For More Daily Tips!