I have a big server application that loads 20 or so modules to plug in
features. These modules are generally plugged in and out based on
circumstances and sometimes to do code maintenance and updates (bug
fixes mainly). These modules are compiled as shared library (.so) and
loaded in and out using dl*() functions family.

The problem is that most of these modules contain a lot of private and
public protocol buffers. So when you unplug a module, there is no way
to do memory cleanup for this specific shared library protocol
buffers. I understand that there is a global
google::protobuf::ShutdownProtobufLibrary() but this will destroy all
descriptors not the ones in this specific shared library.

I understand that there is not an easy way to generically implement
such feature without a big mess. I know a big issue is dependencies so
when I choose to destroy one specific protocol buffer I could break
the internal hierarchy of other dependent buffers. But in my case I
know fore sure that the module being unplugged has no external

There are two ways I could think of to do so. None of them are very
pretty or possible:
1) Use file options. Then when it is unplugging time, look for buffers
with this option and individually remove them from the descriptor
pool. The problem is there is not way to destroy individual protocol
2) Manually call protobuf_ShutdownFile_*_2eproto() function when the
module is being unplugged. However this solution isn't very pretty
because it is using an internal function that could go away or change.

Any suggestions?

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to