blob: b64cb3af37cf2c2e1f7cf159a14661886bca106f [file] [log] [blame]
James Kuszmaulb3fb78a2024-05-09 15:35:29 -07001#include "aos/ipc_lib/memory_estimation.h"
2
3#include "aos/ipc_lib/memory_mapped_queue.h"
4namespace aos::ipc_lib {
5size_t TotalSharedMemoryUsage(const aos::Configuration *config,
6 const aos::Node *node) {
7 size_t total_size = 0;
Austin Schuh6bdcc372024-06-27 14:49:11 -07008 const flatbuffers::Vector<flatbuffers::Offset<aos::Channel>> *channels =
9 config->channels();
10 CHECK(channels != nullptr);
11 for (const aos::Channel *channel : *channels) {
James Kuszmaulb3fb78a2024-05-09 15:35:29 -070012 if (aos::configuration::ChannelIsReadableOnNode(channel, node)) {
13 total_size +=
14 LocklessQueueMemorySize(MakeQueueConfiguration(config, channel));
15 }
16 }
17 return total_size;
18}
19} // namespace aos::ipc_lib