Updated FAQ (markdown)

Benoît Blanchon
2016-09-09 17:56:03 +02:00
parent c3fa002fb4
commit df4e15bc6e

18
FAQ.md

@@ -86,22 +86,20 @@ See issues [#233](https://github.com/bblanchon/ArduinoJson/issues/233), [#234](h
| `StaticJsonBuffer` | `DynamicJsonBuffer`
---------------- | ------------------- | -------------------
Size | fixed | variable :+1:
Location | stack<sup>(1)</sup> | heap
Location | stack :warning: <sup>(1)</sup> | heap
Memory overhead | small :+1: | big
Code size | small :+1: | big
Speed | fast :+1: | slow<sup>(4)</sup>
Cleanup | automatic<sup>(2)</sup> | automatic
Reusable | no<sup>(3)</sup> | no<sup>(3)</sup>
Speed | fast :+1: | slow<sup>(3)</sup>
Cleanup | automatic | automatic
Reusable | no<sup>(2)</sup> | no<sup>(2)</sup>
<sup>(1)</sup> preferably, but if you need you could allocate it in the heap with `new StaticJsonBuffer<200>()` <br>&nbsp;&nbsp;&nbsp;This can be useful on platforms where stack size is limited.
<sup>(1)</sup> :warning: on most platforms, the stack cannot occupy all the RAM; for instance, it's limited to 4KB on the ESP8266.
<sup>(2)</sup> if allocated on the stack, see <sup>(1)</sup>
<sup>(2)</sup> there is a workaround (see [How to reuse a `JsonBuffer`?](#how-to-reuse-a-jsonbuffer) if you are looking for troubles).
<sup>(3)</sup> there is a workaround (see issues [#72](https://github.com/bblanchon/ArduinoJson/issues/72) and [#115](https://github.com/bblanchon/ArduinoJson/issues/115)) for those who are looking for troubles.
<sup>(3)</sup> A `DynamicJsonBuffer` calls `malloc()` to allocate its memory, and it may have to do this several times if it needs to grow. However, you can specify an initial size to the constructor, so as to make sure that the buffer is big enough and that no further allocation will be needed.
<sup>(4)</sup> A `DynamicJsonBuffer` calls `malloc()` to allocate its memory, and it may have to do this several times if it needs to grow. However, you can specify an initial size to the constructor, so as to make sure that the buffer is big enough and that no further allocation will be needed.
As a general rule, if your `StaticJsonBuffer` is bigger than 2K, then it may be a good time to switch to a `DynamicJsonBuffer`.
:information_source: As a general rule, if your `StaticJsonBuffer` is bigger than 2KB, then it may be a good time to switch to a `DynamicJsonBuffer`.