JsonDocument::capacity()
returns the capacity of the memory pool of the JsonDocument
.
Unlike JsonDocument::memoryUsage()
, the result of JsonDocument::capacity()
doesn’t change during the life of the JsonDocument::memoryUsage()
.
For StaticJsonDocument
, the result is always equal to the capacity set as a template parameter.
For DynamicJsonDocument
, the result should be equals to the capacity set in the constructor, but it can be zero if the memory allocation failed.
Use this function to check that the memory allocation succeeded.
Signature ExampleStaticJsonDocument
StaticJsonDocument<256> doc;
doc.capacity(); // 256
DynamicJsonDocument
DynamicJsonDocument doc(1024);
doc.capacity(); // 1024
Zero when allocation fails
DynamicJsonDocument doc(1000000000);
doc.capacity(); // 0
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4