diff --git a/libraries/AP_Scripting/AP_Scripting.cpp b/libraries/AP_Scripting/AP_Scripting.cpp index db0c86a750..1d19108bd1 100644 --- a/libraries/AP_Scripting/AP_Scripting.cpp +++ b/libraries/AP_Scripting/AP_Scripting.cpp @@ -94,6 +94,7 @@ const AP_Param::GroupInfo AP_Scripting::var_info[] = { // @Bitmask: 3: log runtime memory usage and execution time // @Bitmask: 4: Disable pre-arm check // @Bitmask: 5: Save CRC of current scripts to loaded and running checksum parameters enabling pre-arm + // @Bitmask: 6: Disable heap expansion on allocation failure // @User: Advanced AP_GROUPINFO("DEBUG_OPTS", 4, AP_Scripting, _debug_options, 0), diff --git a/libraries/AP_Scripting/AP_Scripting.h b/libraries/AP_Scripting/AP_Scripting.h index 26729b6769..869e11df54 100644 --- a/libraries/AP_Scripting/AP_Scripting.h +++ b/libraries/AP_Scripting/AP_Scripting.h @@ -159,6 +159,7 @@ public: 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 1a6da1bd72..6710f328a2 100644 --- a/libraries/AP_Scripting/lua_scripts.cpp +++ b/libraries/AP_Scripting/lua_scripts.cpp @@ -44,7 +44,8 @@ lua_scripts::lua_scripts(const AP_Int32 &vm_steps, const AP_Int32 &heap_size, AP : _vm_steps(vm_steps), _debug_options(debug_options) { - _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() {