Hi,
I am new of capnp but trying to use it in C++ to send messages over a network.
I am trying to construct 100 capnp messages in a loop and store them in a std::vector before I send them.
My schema looks like this:
struct Message {
field1 @0 : Text;
field2 @1 : Int64;
}
The majority of my fields are Text, there are 35 fields overall.
I am then constructing the messages like this:
std::vector<kj::Array<capnp::word>> _msgs;
_msgs.resize(100);
MSG_1_CLASS _msg_1_class;
capnp::MallocMessageBuilder messagebuilder;
for (int i=0; i<100; i++) {
Message::Builder message = messagebuilder.initRoot<Message>();
message.field1(_msg_1_class.field1.c_str());
message.field2(_msg_1_class.field2);
_msgs[i] = capnp::messageToFlatArray(messagebuilder);
}
The problem that I am having with this is that my memory usage is extreamly high (260 KB per message) measured using /usr/bin/top.
Thanks,
Henry