I have a storage manager written in C++, and I want to pass some objects from Julia to the C++ program. It's enough for me to receive the content as an array of bytes that can later be passed back to Julia and be easily decoded.
What is the best approach that minimizes the number of copying data around (and also avoids writing/reading to/from disk)?
It's possible to allocate the required memory from the C++ program and share it with Julia to serialize the object, or get a pointer to the allocated memory from Julia into the C++ program. In the latter case, I am not sure how to prevent garbage collection from Julia side. Also, I do not know which serialization/deserialization method is more suitable for such a use case.
Would you please guide me to find the best approach for this kind of lightweight serialization/deserialization between Julia and C++?
edit: if the answer is OS-dependent, please give the answer for Linux or macOS.
serialize
anddeserialize
in Julia "will not work if the reading and writing are done by different versions of Julia, or an instance of Julia with a different system image" – Colin T Bowers Jan 21 '18 at 21:51serialize
anddeserialize
is one of the reasons that I'm looking for a solution that works in long-term. I've also edited the question with the OS information. – Mohammad Dashti Jan 22 '18 at 9:04