diff --git a/libraries/AP_Scripting/AP_Scripting.h b/libraries/AP_Scripting/AP_Scripting.h index 0aee427f8dcb1f..4f25e0235bdb50 100644 --- a/libraries/AP_Scripting/AP_Scripting.h +++ b/libraries/AP_Scripting/AP_Scripting.h @@ -151,6 +151,7 @@ class AP_Scripting LOG_RUNTIME = 1U << 3, DISABLE_PRE_ARM = 1U << 4, SAVE_CHECKSUM = 1U << 5, + DISABLE_HEAP_EXPANSION = 1U << 6, }; private: diff --git a/libraries/AP_Scripting/lua_scripts.cpp b/libraries/AP_Scripting/lua_scripts.cpp index c78c0327f324b5..f7f7c8cd7d71c3 100644 --- a/libraries/AP_Scripting/lua_scripts.cpp +++ b/libraries/AP_Scripting/lua_scripts.cpp @@ -45,7 +45,8 @@ lua_scripts::lua_scripts(const AP_Int32 &vm_steps, const AP_Int32 &heap_size, AP _debug_options(debug_options), terminal(_terminal) { - _heap.create(heap_size, 4); + const bool allow_heap_expansion = !option_is_set(AP_Scripting::DebugOption::DISABLE_HEAP_EXPANSION); + _heap.create(heap_size, 10, allow_heap_expansion, 20*1024); } lua_scripts::~lua_scripts() {