Skip to content

RAM Usage on Embedded System – Advice Needed on Optimization #24

@sylque

Description

@sylque

Hi @Blake-Madden,

I'm working with the library on an embedded system and running into RAM usage issues. I’m looking for guidance on whether to submit feature requests or pursue internal customizations to reduce memory consumption.

Context

  • System constraints: Embedded environment with limited memory
  • Usage pattern:
    • ~100 simultaneous pre-compiled expressions (te_parser instances)
    • Most expressions are simple (often just a single variable)
    • Each expression is initialized with ~50 variables (each typically uses only 1–2, but it's not known in advance which ones)

I’m already using TE_NO_BOOKKEEPING, but I’m still seeing significant heap usage. My current assumption is that much of this comes from storing variable names (in m_customFuncsAndVars and possibly elsewhere). For example:

100 expressions × 50 variables × ~8 bytes per name = ~40 KB of heap used for variable names alone

Questions

  1. Is this analysis accurate?
    Are all variable names stored for each expression, regardless of usage? Are those names still needed for evaluation after compilation?

  2. Can variable names be freed after compilation?
    I tried calling expression.set_variables_and_functions({}) post-compilation, but then of course evaluation fails as this removes all te_variable instances, not only names.

  3. Is there a way to remove unused variables post-compilation?
    I'm considering enabling bookkeeping, then using is_function_used() and remove_variable_or_function() to prune unused variables after compilation. Is this a viable approach?

Any insight or suggestions would be greatly appreciated!

Thanks,
Sylvain

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions