ESP - Week 5 Flashcards
Find how much memory a variable takes
sizeof(datatype)
Avoiding global scope
Pass variables with parameters
Use return
What is *p
The value of a variable called p
How to default a pointer
Make it = NULL
How to find the address of a variable
Use &
What does malloc do
Reserve the amount of memory needed for a data type
Malloc cast
a = (b *)malloc
How to free up used memory
free(variable_name)
SRAM divisions
Static data: global and static variables
Heap: dynamic variables (malloc)
Stack: function calls
Why should recursion be avoided
It can take up memory and cause crashes
Why use char instead of string
String tends to use malloc and free which can cause heap fragmentation
What is heap fragmentation
When a pointer is lost and memory cannot be freed
How to put a variable in the flash memory
F()
How to use eeprom
EEPROM.read
EEPROM.write
Why is eeprom update better than write
It will only use memory if the value is different to in the address