econjack:
since I have memory resources to waste, why not waste them?
If there is enough, because there are many variants of the ESP8266 (at least in the board and its features). I know there are differences in flash storage, but is the RAM all the same? If it is, then is just matter of taking a look in the datasheet.
econjack:
You do realize that if fragmentation goes deep enough, your program will crash regardless of resource depth, right?
True, but I thought I could still make a reliable program using String; as long as I don't declare them locally (that creates and destroys) and don't create substrings.
Call me lazy if you want, the thing is that I don't wanna overcomplicate myself and my code; although if I have no other choice to save reliability, then I would take the C way.
Is not that hard when you know how pointers work, so is not a big deal if I have to...
If the rudimentary dynamic memory (heap) manager is quite buggy, I will believe you; otherwise fragmentation shouldn't be that pronounced when executing repetitive tasks (I think)...
Robin2:
Let's face it, that's why the String class was invented and large quantities of RAM are made available to us. When writing a program in Python on a PC I am, effectively, using them all the time.
In an enviroment with plenty of RAM, its use is actually even encouraged; most likely because that runtime enviroment has a garbage collector and it's multithreaded.
Microcontrollers can't afford such feature; since they don't have large enough RAM and can't do true multitasking (DMA doesn't count). Garbage collection will punish their overall performance pretty badly; if such thing existed in an AVR, the program would completely freeze for several seconds every time it's triggered.
That's why I call their dynamic memory manager "rudimentary", in fact I don't even know how it keeps track of all free spaces while respecting the stack.
Robin2:
Presumably the risk is somewhat lower on an ESP8266 - but, unlike a PC, it does not have an operating system to protect me from myself
That's the conflict I'm having right now. ESPs have more RAM, but I usually blame (at first glance) String when people claim random freezes.
Maybe if I pre-allocate global strings with sufficient space before anything else should do the trick; because otherwise that's exactly what I will end up doing with C-strings.
Robin2:
Always - most likely when you are trying to impress a good friend.
In my case: "when I most need it".
I can't sacrifice reliability, because I don't want to realize that the ESP froze and doesn't respond to my commands in an uncomfortable situation.