Heap or Stack??
Posted: Mon Dec 28, 2020 12:22 pm
Very knowledgeable about C when it involves heap and stack and variables, but in the CPP world it can be very different... still learning...
I would assume the answer is always stack... but is it?? does the Arduino String do anything heap-side?
void func() {
String s1; // heap or stack?
int x; // i know this is stack
String s2 = s1 + "temp"; // s2 heap or stack, intermeadiate "temp" heap or stack?
int x1 = x + 2; // i know this is still all stack
// if these strings are on the heap, are they removed when the function exits?
}
RichardS
I would assume the answer is always stack... but is it?? does the Arduino String do anything heap-side?
void func() {
String s1; // heap or stack?
int x; // i know this is stack
String s2 = s1 + "temp"; // s2 heap or stack, intermeadiate "temp" heap or stack?
int x1 = x + 2; // i know this is still all stack
// if these strings are on the heap, are they removed when the function exits?
}
RichardS