I would like to use Google Protocol Buffers in a memory constrained environment - not so much that the environment is low on memory as much as memory usage is tracked on a per subsystem basis.
Generally, in this environment for other non-Google Protocol Buffers, I use the C++ placement new operator, which allows me to allocate a buffer from a specializes allocator and pass the address of that buffer to the new() operator.
char* fooAllocation = memoryBroker->Allocate(MY_SUBSYSTEM_ID, MAX_FOO_SIZE);
class Foo foo* = new (fooAllocation);
When I am done with foo, I can call
memoryBroker->Free(MY_SUBYSTEM_ID, MAX_FOO_SIZE, foo);
That allows memoryBroker to keep accurate stats on memory usage by subsystem.
I'd like to do the same with a GPB message.
Is there some way to do that?
Mike