Protobuf support for custom allocator ??

26 views
Skip to first unread message

Gaurav Jain

unread,
Aug 10, 2020, 2:57:25 AM8/10/20
to Protocol Buffers
Does protocol buffer supports allocating entries on custom allocator. Basically my requirement is to use PMEM as my extended DRAM. I am using libmemkind library for allocating/deallocating stuffs from PMEM.
I have few protobuf objects on DRAM which I need to move to pmem using libmemkind. 
One way is to serialize these protobuf objects and copy raw bytes, but this will incur serialization and deserialization penalties. Is there a way to copy deserialized objects itself from DRAM to PMEM ? This can be doable if protobuf can support custom allocator while creating new objects.

Adam Cozzette

unread,
Aug 10, 2020, 12:59:02 PM8/10/20
to Gaurav Jain, Protocol Buffers
No, unfortunately C++ protobuf does not support custom allocators. The closest you can get is to use Arena allocation and give your Arena an initial block of memory to use, but not everything will be allocated on the arena. String and bytes fields use std::string, so strings will end up stored on the heap.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/cb56a2a7-75a1-4da5-925a-afbfdb3bb474n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages