Hello all,

I don't fully understand how some of this memory stuff with C works on the calculator (TI84+ CE). I found this https://www.cemetech.net/forum/viewtopic.php?t=19920 topic but it doesn't go into too much detail about why. This is my current understanding as well as some questions I have.

• Calling malloc() is discouraged because it is slow. I should statically allocate instead.
○ Is speed the only reason against using malloc()?
○ Is the call to malloc() the slow part or is it slower to access heap memory?
○ Will the toolchain or OS free() my memory or do I need to do that myself at the end of the program? What about functions like gfx_MallocSprite(), do I free that memory too?

Quote:
Just statically allocate.

○ There's nothing special about statically allocating, right? You just

Code:
 int my_var[100];

Should these forum members decide to grace me with their wisdom, I would be very grateful. 😁
This is all documented here: https://ce-programming.github.io/toolchain/static/coding-guidelines.html#avoid-dynamic-allocation

The toolchain will free memory you allocate on exit, but that's generally bad practice to rely on.
Quote:

Thank you very much. I had not noticed that section on the toolchain
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement