Repository navigation
Dmod_MallocTagged: memory of a kind, else the default memory - #332
Merged
Merged
Conversation
Tags - kinds of memory, preferred first, separated by commas ("fast",
"dma", ...) - as the system tags its heaps (dmheap: a heap's name is the
list of its tags). A kind the system does not have, or one without room:
the next one, at last Dmod_MallocEx()'s memory. The default implementation
is Dmod_MallocEx(), so a module asks for what it gains from and works
anywhere - on the host too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JohnAmadis
self-requested a review
October 17, 2026 18:01
JohnAmadis
approved these changes
Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A module can ask for memory of a kind:
Tags- kinds of memory, preferred first, separated by commas:"fast"(internal RAM worth giving to what is worked on all the time),"dma"(memory DMA reaches without cache maintenance), ... - as the system tags its heaps;Dmod_MallocEx()gives;Dmod_MallocTaggedEx(Tags, Size, ModuleName)is the builtin; its default (weak) implementation isDmod_MallocEx()- on the host, or a system without heaps of kinds, a module asking for a kind still works.dmheap implements it on a device: a heap's name becomes the list of its tags (choco-technologies/dmheap PR), dmod-boot tags its heaps.
Why
On the STM32F746G Discovery everything a module allocates lands in the SDRAM (the newest default heap), behind a 4 kB data cache. dmmp3's decoder state (23 kB, worked on for every frame) there took 70 % of the CPU to decode an MP3; in the DTCM 15 % - carhmi-demo's view went from a few frames a second to 25. A module had no way to ask for internal memory without depending on dmheap - which exists only in the firmware, so the module would not load on the host.
Tests
tests_dmod_malloc_tagged: without heaps of kinds, memory of any kind (and none,NULL,"") is the default memory.🤖 Generated with Claude Code