I had been having problems due to stack overflow (see https://www.b4x.com/android/forum/t...-when-using-ssl-connection.114046/post-712328)
On further investigation it appeared that my code was using quite a lot of RAM before anything was actually running. In other words, reading AvailableRAM even immediately upon AppStart showed it was already down by a massive 16K! Ok so I could account for some of that being due to my allocating a larger buffer stack (4K) but that still left 12K. The Global variables only accounted for a few hundred bytes, so where was it all going before the code even started doing anything? Somewhat onerously after some trial and error, adding bits of the original code back, compiling, then checking RAM at Appstart I eventually discovered that the main offender was an area where I was using lots of Astream.writes followed by explicit strings, e.g Astream.write("This eats up RAM before you even use this Sub"). I had wrongly assumed that such constructs would be stored in the code flash until called upon by the running code, but evidently it is not so?
So question is - how might I better deal with this type of thing? Perhaps answering my own question, I'm guessing I need to understand and use the rESP8266FileSystem which is probably more sensible all round, but how does one get all the strings into the file system in the first place? Does it mean that I can't do this from within the code/compiler itself because I'd end up with the same RAM allocation issue anyway?
On further investigation it appeared that my code was using quite a lot of RAM before anything was actually running. In other words, reading AvailableRAM even immediately upon AppStart showed it was already down by a massive 16K! Ok so I could account for some of that being due to my allocating a larger buffer stack (4K) but that still left 12K. The Global variables only accounted for a few hundred bytes, so where was it all going before the code even started doing anything? Somewhat onerously after some trial and error, adding bits of the original code back, compiling, then checking RAM at Appstart I eventually discovered that the main offender was an area where I was using lots of Astream.writes followed by explicit strings, e.g Astream.write("This eats up RAM before you even use this Sub"). I had wrongly assumed that such constructs would be stored in the code flash until called upon by the running code, but evidently it is not so?
So question is - how might I better deal with this type of thing? Perhaps answering my own question, I'm guessing I need to understand and use the rESP8266FileSystem which is probably more sensible all round, but how does one get all the strings into the file system in the first place? Does it mean that I can't do this from within the code/compiler itself because I'd end up with the same RAM allocation issue anyway?