From be2d10ff457a1153fe073acd8f5e761465548e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 29 Mar 2017 14:25:52 +0200 Subject: [PATCH] px4_nuttx_tasks: call clearenv() before task_create Frees up around 6kB of RAM on Pixracer & Pixhawk. --- src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c b/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c index 122da39d05..1bf359d617 100644 --- a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c +++ b/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c @@ -74,6 +74,13 @@ int px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_ sched_lock(); + /* None of the modules access the environment variables (via getenv() for instance), so delete them + * all. They are only used within the startup script, and NuttX automatically exports them to the children + * tasks. + * This frees up a considerable amount of RAM. + */ + clearenv(); + /* create the task */ pid = task_create(name, priority, stack_size, entry, argv);