diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index 9a159fb28a..cb5dfe6e2d 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -70,7 +70,7 @@ SerializationBuffer<> JsonBuilder::serialize() { // directly in the caller's stack frame, eliminating the move constructor call entirely. // // WITHOUT NRVO: Each return would trigger SerializationBuffer's move constructor, which - // must memcpy up to 768 bytes of stack buffer content. This happens on EVERY JSON + // must memcpy up to 512 bytes of stack buffer content. This happens on EVERY JSON // serialization (sensor updates, web server responses, MQTT publishes, etc.). // // WITH NRVO: Zero memcpy, zero move constructor overhead. The buffer lives directly @@ -89,7 +89,7 @@ SerializationBuffer<> JsonBuilder::serialize() { // Should show only destructor, NOT move constructor // // Why we avoid measureJson(): It instantiates DummyWriter templates adding ~1KB flash. - // Instead, try stack buffer first. 768 bytes covers 99.9% of JSON payloads (sensors ~200B, + // Instead, try stack buffer first. 512 bytes covers 99.9% of JSON payloads (sensors ~200B, // lights ~170B, climate ~700B). Only entities with 40+ options exceed this. // // =========================================================================================== diff --git a/esphome/components/json/json_util.h b/esphome/components/json/json_util.h index 95a9d25194..3ea551bc8e 100644 --- a/esphome/components/json/json_util.h +++ b/esphome/components/json/json_util.h @@ -17,9 +17,9 @@ namespace esphome { namespace json { /// Buffer for JSON serialization that uses stack allocation for small payloads. -/// Template parameter STACK_SIZE specifies the stack buffer size (default 768 bytes). +/// Template parameter STACK_SIZE specifies the stack buffer size (default 512 bytes). /// Supports move semantics for efficient return-by-value. -template class SerializationBuffer { +template class SerializationBuffer { public: static constexpr size_t BUFFER_SIZE = STACK_SIZE; ///< Stack buffer size for this instantiation @@ -175,7 +175,7 @@ class JsonBuilder { } /// Serialize the JSON document to a SerializationBuffer (stack-first allocation) - /// Uses 768-byte stack buffer by default, falls back to heap for larger JSON + /// Uses 512-byte stack buffer by default, falls back to heap for larger JSON SerializationBuffer<> serialize(); private: