Skip to content

Teensy 4: Channel API costs ~72 KB RAM1 because ChannelManager::instance() registers every driver #4708

Closed

Description

@zackees

Report

From a user on Reddit:

It looks like ChannelManager::instance() calls initChannelDrivers(), which now registers all drivers unconditionally on Teensy 4 and bloats the ITCM memory used? If I switch from the legacy addLeds() approach to the channels API, it costs me ~72KB of RAM1 in my current project. Let me know if you want any help investigating this one.

The user offered to help investigate.

What the code does

  • ChannelManager::instance() (src/fl/channels/manager.cpp.hpp) calls platforms::initChannelDrivers() the first time it runs.
  • On Teensy 4.x, initChannelDrivers() (src/platforms/arm/teensy/teensy4_common/init_channel_driver_mxrt1062.cpp.hpp) always registers three engines:
    • FlexIO, through BusTraits<Bus::FLEX_IO, 1>
    • ObjectFLED DMA, through BusTraits<Bus::FLEX_IO, 0>
    • unified SPI hardware
  • Any sketch that uses the Channel API therefore links in every engine, whether or not it uses them. On Teensy 4, code goes into ITCM by default (FASTRUN/RAM1), so that dead code also takes up RAM1.
  • The legacy addLeds<> slim bridge goes through ChannelManager::registry(), which only registers the bus that is actually used. That is why it doesn't pay this cost.

Expected

Using the Channel API should only link (and spend RAM1 on) the engines the sketch actually uses, the same way the registry() / enableDrivers<> opt-in path already does.

Next steps

  • Measure RAM1/ITCM with bash bloat teensy41 for a sketch using addLeds<> and the same sketch using the Channel API.
  • Options:
    • Make the Teensy 4 registration opt-in or demand-driven, keyed on the requested bus.
    • Keep any engine not selected for the sketch out of .text in ITCM by placing it in flash (FLASHMEM).

Activity

  1. added a commit that references this issue on Oct 6, 2026
    2d15bc9
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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions