Below is some simple code with ZMQ.
zmq::socket_t MPC1Socket(context, ZMQ_DEALER);
If (MPC1Socket != NULL) MPC1Socket.close();
If (context != NULL) context.close();
Strangely enough, I got the following error when profiling it in valgrind.
# valgrind --leak-check=full --suppressions=./valgrind.supp ./MasterInterface
==11063== Invalid free() / delete / delete / realloc() ==11063== at 0x4C2AD17: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==11063== by 0x5C25A8B: __libc_freeres (in /usr/lib64/libc-2.17.so) ==11063== by 0x4A246B4: _vgnU_freeres (in /usr/lib64/valgrind/vgpreload_core-amd64-linux.so) ==11063== by 0x5AFAE0A: __run_exit_handlers (in /usr/lib64/libc-2.17.so) ==11063== by 0x5AFAE94: exit (in /usr/lib64/libc-2.17.so) ==11063== by 0x5AE3AFB: (below main) (in /usr/lib64/libc-2.17.so) ==11063== Address 0x5e7c3d0 is 0 bytes inside data symbol "noai6ai_cached"
Change localhost to 127.0.0.1. (don’t ask me why)
Not saying that this is definitely the issue when you encounter the freeres problem. But you could give it a try.