Go Down

Topic: ArduinoJson memory leak (Read 691 times) previous topic - next topic

bstsoft

Hi
 script
 DynamicJsonBuffer ox_jsonBuffer(64);
 JsonArray& ox = ox_jsonBuffer.createArray();
 uint32_t ix = 0;
 void timerIsr2()//Демонстрация утечки памяти
 {
 Serial.println("heap:"+String(ESP.getFreeHeap())+"***ix="+(String)ix);
 Serial.println("size:"+(String)ox.size());
 while(ox.size())
 {
 ox.removeAt(0);
 }
 Serial.println("size:"+(String)ox.size());
 JsonObject& ox_item = ox.createNestedObject();
 Serial.println("size:"+(String)ox.size());
 Serial.println("heap:"+String(ESP.getFreeHeap()));
 ix++;
 }

********************** log
 Server started
 heap:30904***ix=0
 size:0
 size:0
 size:1
 heap:30904
 heap:28920***ix=51
 size:1
 size:0
 size:1
 heap:28920
 heap:26856***ix=101
 size:1
 size:0
 size:1
 heap:26856
 heap:26856***ix=151
 size:1
 size:0
 size:1
 heap:26856
 heap:22744***ix=201
 size:1
 size:0
 size:1
 heap:22744
 heap:22744***ix=301
 size:1
 size:0
 size:1
 heap:22744
 heap:22744***ix=401
 size:1
 size:0
 size:1
 heap:22744
 heap:14368***ix=1298
 size:0
 size:0
 size:0
 heap:14368

bstsoft

the thing is DynamicJsonBuffer when you call size()
Serial.println("heap:"+String(ESP.getFreeHeap())+"***ix="+(String)ix+"***size:"+(String)ox_jsonBuffer.size());
I see the picture
heap:30168***ix=27***size:548
heap:14744***ix=473***size:9468
then the question arises how to clean DynamicJsonBuffer?

pert

bstsoft's issue report:
https://github.com/arduino/Arduino/issues/6291

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

When your code requires a library that's not included with the Arduino IDE please always post a link(using the chain link icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

You need to post a minimal complete sketch that demonstrates the problem, not a fragment of a sketch.

Get rid of all this pointless use of String. There's a chance that's the cause of the memory leak, not the library.

You're being very disrespectful by dropping such a half-assed issue report on the Arduino/arduino issue tracker. 817 PEOPLE GET AN EMAIL FOR EVERY ONE OF YOUR WORTHLESS COMMENTS!!!!!!!!!. That tracker should only be used for verified bugs WITH THE ARDUINO IDE. There is a very good chance this is just user error. If not user error then it may be a bug the in the ArduinoJSON library, which is not written or maintained by the Arduino developers. You should only make an issue on Arduino/arduino repository once you have absolutely determined the bug is with the Arduino IDE. At that time you would want to take the time to provide a detailed, correctly formatted report that lists all steps necessary to reproduce the bug. By wasting the time of the Arduino developers you are stealing from this entire community. The time they spend dealing with your issue is time they can't spend doing real development work that benefits all of us. Please have more respect.

Go Up