Skip to content

Improve RAM usage related to setjmp/longjmp #1474

Description

@thschalch

The platform specific implementations of setjmp/longjmp use a stack of 10 jump buffers (jmp_buf):

static jmp_buf test_exit_jmp_buf[10];

The size of jmp_buf is considerable, depending on the exact platform (e.g. around 256 bytes or more). Having 10 jump buffers statically allocated eats kilobytes of memory, which may be a big part of the whole test application on embedded devices.

The stack of 10 jump buffers is needed to be able to make nested setjmp/longjmp calls. However, as far as I see, a stack size of 2 would be sufficient (needed in UTest::run).

Suggestions to reduce RAM usage:

  • The array size of jmp_buf can be safely reduced to 2 on all platforms.
  • If exceptions are used, the array of jmp_buf is still allocated and setjmp/longjmp is also used. Please correct me if I'm wrong, but I do not see the point why both exceptions and setjmp/longjmp are used.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions