{"id":3506,"date":"2022-05-26T11:37:23","date_gmt":"2022-05-26T09:37:23","guid":{"rendered":"https:\/\/store.algosyntax.com\/?post_type=asx-lms-tutorial-cpt&#038;p=3506"},"modified":"2026-03-09T01:37:51","modified_gmt":"2026-03-08T23:37:51","slug":"ue5-variable-is-optimized-away-and-not-available","status":"publish","type":"asx-lms-tutorial-cpt","link":"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/ue5-variable-is-optimized-away-and-not-available\/","title":{"rendered":"UE5 Variable is optimized away and not available when debugging"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3506\" class=\"elementor elementor-3506\" data-elementor-post-type=\"asx-lms-tutorial-cpt\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-406e7b6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"406e7b6\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5c491a7\" data-id=\"5c491a7\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ffcfd1c elementor-widget elementor-widget-text-editor\" data-id=\"ffcfd1c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>In this tutorial, we cover a debugging scenario where you will get the optimized variable message in the <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/debugger\/debugger-feature-tour?view=vs-2022\" target=\"_blank\" rel=\"noopener\">visual studio debugger<\/a> when trying to watch variables. This hinders the debugging process as the developer can not see the variables he needs to troubleshoot.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a5afa07 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a5afa07\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4018b12\" data-id=\"4018b12\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2b58e71 elementor-widget elementor-widget-heading\" data-id=\"2b58e71\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Temporarily Turn Optimizations Off<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ba306f5 elementor-widget elementor-widget-text-editor\" data-id=\"ba306f5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>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 <a href=\"https:\/\/docs.unrealengine.com\/4.27\/en-US\/ProductionPipelines\/BuildTools\/UnrealBuildTool\/ModuleFiles\/\" target=\"_blank\" rel=\"noopener\">build.cs<\/a>.\u00a0<\/p><p>\u00a0<\/p><p>Go to your module&#8217;s build.cs and add this line:<\/p><p>\u00a0<\/p><p><strong>OptimizeCode = CodeOptimization.Never;<\/strong><\/p><p>\u00a0<\/p><p>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.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"featured_media":0,"template":"","asx-lms-tutorial-categories":[48,45],"asx-lms-tutorial-tags":[46,54],"class_list":["post-3506","asx-lms-tutorial-cpt","type-asx-lms-tutorial-cpt","status-publish","hentry","asx-lms-tutorial-categories-unreal-build-tool","asx-lms-tutorial-categories-unreal-engine","asx-lms-tutorial-tags-cpp","asx-lms-tutorial-tags-visual-studio","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/3506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt"}],"about":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/types\/asx-lms-tutorial-cpt"}],"version-history":[{"count":0,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/3506\/revisions"}],"wp:attachment":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/media?parent=3506"}],"wp:term":[{"taxonomy":"asx-lms-tutorial-categories","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-categories?post=3506"},{"taxonomy":"asx-lms-tutorial-tags","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-tags?post=3506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}