10000 JsonDocument dynamic allocation problem · Issue #1480 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
JsonDocument dynamic allocation problem #1480
@Leo-C

Description

@Leo-C

Hi,
the title not refers to DynamicJsonDocument, but it refers precisely to dinamic allocation of a JsonDocument with new !

My environment is:
Platform: ESP32 TTGO
IDE: Arduino IDE 1.8.13

The simple code below compile well, but crash at delete:

#include <Arduino.h>
#include <ArduinoJson.h>

void setup()
{
	Serial.begin(115200);
}

void loop()
{
	Serial.println("Mem before: " + String(ESP.getFreeHeap()));
	
	JsonDocument* doc = new DynamicJsonDocument(1024);
	delete doc;
	
	Serial.println("Mem after: " + String(ESP.getFreeHeap()));
}

(this is a minimal example for a scenario where I allocate dinamically a JsonDocument into a function, return a pointer, and only after use, I call destructor in a different scope with delete in a different scope)

I appreciate any help to understand my error

Many thanks in advance

Leonardo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv6ArduinoJson 6

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0