AP_Scripting: added ability to expand heap at runtime if armed

This commit is contained in:
Andrew Tridgell 2024-03-15 13:49:13 +11:00
parent 66752996e4
commit a5ff7f83d1
3 changed files with 4 additions and 1 deletions

View File

@ -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),

View File

@ -159,6 +159,7 @@ public:
LOG_RUNTIME = 1U << 3,
DISABLE_PRE_ARM = 1U << 4,
SAVE_CHECKSUM = 1U << 5,
DISABLE_HEAP_EXPANSION = 1U << 6,
};
private:

View File

@ -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() {