How to interpret the difference in memory size between Teensy 4.1 and Due ?

Status
Not open for further replies.

Ed70

Member
I am in the process of transferring my project on my arduino due to the Teensy 4.1.
One of the main reasons for this is the memory usage of my sketch.
If I compare the memory usage of the sketch between the Due and the Teensy, the Teensy uses only 6% against 64% on the Due.
That is the good news, however, the compiler indicates that global variables use 78% of the dynamic memory.
Unfortunately, the compiler does not indicate this consumption for the Due, but I expected that I would have much more memory left with the Teensy. Or am I missing something ? And can extra psram mean anything ?
 
Hard to say what memory is being used and for what...

I have a thread I did awhile ago, that talks some about the different regions of memory on the T4.x, that also shows some tools we hacked up to show additional information and the like:
https://forum.pjrc.com/threads/57326-T4-0-Memory-trying-to-make-sense-of-the-different-regions

Also the T4.x there is additional information up on the main page for the T4: https://www.pjrc.com/store/teensy40.html
(Note: on that page) PROGMEM Code - Functions defined with "PROGMEM"
Should now read: PROGMEM Code - Functions defined with "FLASHMEM"

There have also been a few threads on this recently including:
https://forum.pjrc.com/threads/63435-Noob-question-Measuring-Teensy-4-1-CPU-and-RAM-utilization
 
64% of flash memory used on Due means your program is taking about 328K. That's pretty large.

On Teensy 4.1 many things compete for use of the first 512K of "tightly coupled" RAM. If all 328K of your program gets put into that RAM, it's going to leave only 184K for everything else. The good news is Due's RAM is only 96K, so odds are very good everything will fit even in the worst case of everything packing into the first 512K RAM. But you might not end up with much of that first 512K left over.

The 2 easy things you can do to keep some of that 328K from consuming TCM RAM is use of FLASHMEM on functions which aren't speed critical, and PROGMEM on any arrays of constant data which isn't speed critical.

You can also get access to the other 512K with malloc(). So if you have any large arrays or buffers, you might edit your code slightly to allocate those at startup with malloc() rather than having them as global or static variables.

But TCM RAM (the first 512K) is the fastest memory. That's why so many things default to using it. If you want maximum performance, best to just go with the defaults. You can always do this stuff if you need more of the TCM space if your code & memory requirements grow.
 
thanks for your extra clarification Paul.
it's clearer to me now and I'm going to try out some suggestions.
 
Status
Not open for further replies.
Back
Top