diff --git a/docs/software/ramusage-nrf52.txt b/docs/software/ramusage-nrf52.txt index 7258539f..9969806e 100644 --- a/docs/software/ramusage-nrf52.txt +++ b/docs/software/ramusage-nrf52.txt @@ -1,12 +1,22 @@ 23K + messages -+ heap of 30ish packets, 300ish bytes per packet: 8KB ++ heap of 70ish packets, 300ish bytes per packet: 20KB + 14KB soft device RAM +With max length Data inside the packet +Size of NodeInfo 104 +Size of SubPacket 272 +Size of MeshPacket 304 + +If Data was smaller: for 70 data packets we would save 7KB. We would need to make SubPacket.data and MeshPacket.encrypted into "type:FT_POINTER" - variably sized mallocs +Size of NodeInfo 104 +Size of SubPacket 96 +Size of MeshPacket 292 (could have been much smaller but I forgot to shrink MeshPacket.encrypted) + therefore: a) we should store all ToPhone message queued messages compressed as protobufs (since they will become that anyways) b) shrink packet pool size because none of that storage will be used for ToPhone packets c) don't allocate any storage in RAM for the tophone messages we save inside device state, instead just use nanopb callbacks to save/load those -d) a smarter MeshPacket in memory representation would save about 4KB of RAM? +d) a smarter MeshPacket in memory representation would save about 7KB of RAM. call pb_release before freeing each freshly malloced MeshPacket 2000790c 00003558 B devicestate // 16KB 2000b53c 00001000 b _cache_buffer // 4KB flash filesystem support diff --git a/lib/nanopb/include/pb.h b/lib/nanopb/include/pb.h index 8e87b626..45504e99 100644 --- a/lib/nanopb/include/pb.h +++ b/lib/nanopb/include/pb.h @@ -11,7 +11,7 @@ *****************************************************************/ /* Enable support for dynamically allocated fields */ -/* #define PB_ENABLE_MALLOC 1 */ +#define PB_ENABLE_MALLOC 1 /* Define this if your CPU / compiler combination does not support * unaligned memory access to packed structures. */ diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 444ccc7a..fa425ddb 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -34,7 +34,12 @@ Allocator &packetPool = staticPool; * * Currently we only allow one interface, that may change in the future */ -Router::Router() : fromRadioQueue(MAX_RX_FROMRADIO) {} +Router::Router() : fromRadioQueue(MAX_RX_FROMRADIO) +{ + DEBUG_MSG("Size of NodeInfo %d\n", sizeof(NodeInfo)); + DEBUG_MSG("Size of SubPacket %d\n", sizeof(SubPacket)); + DEBUG_MSG("Size of MeshPacket %d\n", sizeof(MeshPacket)); +} /** * do idle processing