If it's a problem with memory corruption, the only solution is either to fix the library or to kill and restart the program to let the OS clean up the address space. If the issue is very serious, you could write a daemon-like program that uses the library and keep the main parts of your code in a separate program. Then you just open a pipe to the daemon and make requests for data processing. If the daemon crashes, the main program can just restart it and proceed as normal, without losing any program state.