Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 4 dynamic memory space

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    6

    Teensy 4 dynamic memory space

    Hi,

    I have a project for my Teensy 4 that I initially wrote using Arduino 1.8.10 and Teensyduino 1.48. When I compile it I still have plenty of dynamic memory available:

    Code:
    Sketch uses 125744 bytes (6%) of program storage space. Maximum is 2031616 bytes.
    Global variables use 497200 bytes (47%) of dynamic memory, leaving 551376 bytes for local variables. Maximum is 1048576 bytes.
    I just upgraded to Teensyduino 1.52 and the results are much different. It seems half the dynamic memory is missing:

    Code:
    Sketch uses 127024 bytes (6%) of program storage space. Maximum is 2031616 bytes.
    Global variables use 529076 bytes (100%) of dynamic memory, leaving -4788 bytes for local variables. Maximum is 524288 bytes.
    data section exceeds available space in board
    As you can see the memory usage and availability is much different. I'm using the same libraries and same code. Why has the maximum available memory been cut in half between these versions? What did I miss?

    Thanks for your time.
    Last edited by stivo; 06-11-2020 at 10:37 AM.

  2. #2
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    569
    In version 1.48 dynamic memory consisted of both RAM1 and RAM2 combined, if RAM2 was never used then any program that was compiled showing over 50% of dynamic memory usage would cause an error. This obviously caused confusion for those who weren’t aware of RAM2 and that it is not automatically used so in 1.52 it only shows RAM1 to avoid confusion. Since you are using so much memory you should consider placing large uninitialized arrays in RAM2 so you can make use of the other half of available memory.

  3. #3
    Junior Member
    Join Date
    Oct 2018
    Posts
    6
    Quote Originally Posted by vjmuzik View Post
    In version 1.48 dynamic memory consisted of both RAM1 and RAM2 combined, if RAM2 was never used then any program that was compiled showing over 50% of dynamic memory usage would cause an error. This obviously caused confusion for those who weren’t aware of RAM2 and that it is not automatically used so in 1.52 it only shows RAM1 to avoid confusion. Since you are using so much memory you should consider placing large uninitialized arrays in RAM2 so you can make use of the other half of available memory.
    Searching for RAM2 I found another thread where you mentioned "Any calls to malloc or new will go to RAM2...". I initialized some of my large arrays using new and I now have large amounts of dynamic memory available.

    Thanks so much for your help and quick answer. Cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •