Comments (6)
A memory leak is very unlikely if you use StaticJsonBuffer
because there is no dynamic memory allocation.
However, you need to understand that StaticJsonBuffer
holds the JSON tokens until it is out of scope, it's the way it is supposed to work.
You probably just have to move the declaration of the StaticJsonBuffer
inside the loop, so as to reduce the scope of the variable to just were it's needed.
If it doesn't work, please copy/paste the code here.
from arduinojson.
Hi,
Thanks for the email.
I am attaching my test sketch
/***********************************
Possible memory leak or issue during parse:
Look at the messages on serial monitor which say:
Serial.print(F("json buffer contents before parse: "));
Serial.println(json);
// copy the char array to a temp buffer
// because it appears that ArduinoJson lib somehow truncates it
snprintf_P(espbuffer, (sizeof(espbuffer)), PSTR("%s"), json);
Serial.print(F("json buffer contents in temp buffer before parse: "));
and
Serial.print(F("json temp buffer contents after parse: "));
Serial.println(espbuffer);
after the parse the espbuffers' contents appear to be truncated.
also:
with StaticJsonBuffer<300> jsonBuffer;
declared as a global variable, the parse reports failure after the
4th or 5th time thru the loop.
with it declared inside the parse function ( parseTestDataJSON)
no reported parse failures are seen but the
espbuffer is still appears to be truncated.
My concern is that the buffer espbuffer appears to be truncated after
the parse.
I am running arduino 1.06 on an arduino uno r3
I also tried it on an ESPToy from rayshobbys which has a esp8266 wifi module
that I connect to a weatherdata website to data from
you can find it here:: http://rayshobby.net/?p=10156
On this board my pc appears to slow way down when running the test
sketch and my GetWifiWeatherData sketch
Thanks again,
Let me know what you find.
Tom
On 2/23/2015 3:37 PM, Benoît Blanchon wrote:
A memory leak is very unlikely if you use |StaticJsonBuffer| because
there is no dynamic memory allocation.
However, you need to understand that |StaticJsonBuffer| holds the JSON
tokens until it is out of scope, it's the way it is supposed to work.
You probably just have to move the declaration of the
|StaticJsonBuffer| inside the loop, so as to reduce the scope of the
variable to just were it's needed.
If it doesn't work, please copy/paste the code here.—
Reply to this email directly or view it on GitHub
#49 (comment).
from arduinojson.
Hi Tom,
Can you please create a gist with the complete .ino
file?
Also, please have a look at the documentation:
Regards,
Benoit
from arduinojson.
Hi Benoit,
I created a Gist of my test file.
see
https://gist.github.com/Tomega3/2f9e208f61da69edafbf
I have read the memory model and the avoiding pitfalls
I hope this helps
Thanks again,
Tom
On 2/24/2015 4:38 AM, Benoît Blanchon wrote:
Hi Tom,
Can you please create a gist https://gist.github.com/ with the
complete |.ino| file?Also, please have a look at the documentation:
- Memory model
https://github.com/bblanchon/ArduinoJson/wiki/Memory%20model- Avoiding pitfalls
https://arduinojson.org/doc/pitfalls/Regards,
Benoit—
Reply to this email directly or view it on GitHub
#49 (comment).
from arduinojson.
I'm sorry, I think I overlooked your sentence:
My concern is that the buffer espbuffer appears to be truncated after
the parse.
This is an expected behavior, please read carefully Avoiding pitfalls, section 6:
Indeed, the parser modifies the string for two reasons:
- it inserts \0 to terminate substrings,
- it translate escaped characters like \n or \t.
This is how the library works.
It's done this way to avoid memory copy.
If you do need a copy of the original string, you need to make a copy in your program.
from arduinojson.
Thank you very much for the info.
If you want to close and or remove the issue I posted please do so.
Thanks again,
Tom
On 2/24/2015 8:40 AM, Benoît Blanchon wrote:
I'm sorry, I think I overlooked your sentence:
My concern is that the buffer espbuffer appears to be truncated after the parse.
This is an expected behavior, please read carefully Avoiding pitfalls,
section 6
https://arduinojson.org/doc/pitfalls/#6-make-sure-the-string-isnt-read-only:Indeed, the parser modifies the string for two reasons: * it inserts \0 to terminate substrings, * it translate escaped characters like \n or \t.
This is how the library works.
It's done this way to avoid memory copy.
If you do need a copy of the original string, you need to make a copy
in your program.—
Reply to this email directly or view it on GitHub
#49 (comment).
from arduinojson.
Related Issues (20)
- Filtering large arrays of objects HOT 4
- deserializeJson from HTTP result in EmptyInput error HOT 3
- best way to create a sub document HOT 6
- Callback-based filter HOT 1
- Adding entry in JsonObject using File object causes corrupted JSON HOT 1
- Initial serializing HOT 7
- `doc[var]` doesn't work when `var` contains a string
- JsonArray.add(JsonObject) adds partial JsonObject when the JsonDocument is full HOT 6
- ArduinoJson.h: No such file or directory HOT 3
- JsonVariant tests false for both a value that doesn't exist and for a value that is zero HOT 7
- How do i create JSON array of objects using ArduinoJson library. HOT 1
- Identifying JsonVariant type of a deserialized document HOT 4
- Example code results in compiler error: no match for 'operator+=' HOT 3
- Passing JsonDocument by reference HOT 4
- In Memory Deserialization HOT 3
- v7 equivalent of validateJson HOT 2
- conversion from ‘ArduinoJson::V704HB42::detail::enable_if<true, ArduinoJson::V704HB42::JsonVariantConst>::type’ {aka ‘ArduinoJson::V704HB42::JsonVariantConst’} to ‘ArduinoJson::V704HB42::JsonDocument’ is ambiguous HOT 1
- Assertion `poolIndex < count_' failed HOT 1
- Maximum string length of 13 characters HOT 2
- V6 Documentation ArduinoJson PubSubClient with StreamUtils HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinojson.