Skip to content

Handle strings in the sketch - heap problem. #222

Closed
@robertgregor

Description

@robertgregor

Hello, it seems, that all the strings used in the sketch are going to the heap. I have a sketch which is using ESP8266WebServer. In each handler, I am using the Strings to output. Now I've reached the situation, that if I put any more Strings in the sketch, the heap is full. It is very strange, thus based on the hint I am now doing this:
static const char XSD_SW_1[] = "blablba-bigstring";

Then in the handler method:
server.send(200, "text/xml", "");
WiFiClient client = server.client();
client.write(&XSD_SW_1[0], sizeof(XSD_SW_1)-1);

But looks like that that const is a part of the heap, because if I will do XSD_SW_1[] = ""; then everything is OK. If I leave big - aroung 1400 characters - maximum buffer of the Webserver write method, my sketch doesn't work at all - seems, it will even not start correctly.
Is there any way, how to tell to compiler, that the strings should stay on flash and should be read, when it is needed? In arduino, there is for this purpose the F() macro or PROGMEM directive. But I belive, this is avr specific.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions