Forgive me for bumping an old thread, but I too am interested in an answer to this question. As things stand I'm going to commit to using out-of-date APIs in order to accomplish this. But it'd be nice if there were an officially supported and modern way to make socket connections and HTTP / HTTPS requests using a specific network interface.
I was sure I've already tried to make it a member variable of the class and having some error. Not a the compilation but when I tried to launch the app (app was ended forcefully as the messages read).
I had to make a mistake at the time but I can remmber I've done differently.
Ahh sorry I thought an strace would help. It might take me a bit to get an actual stack trace as I'd have to set up my build environment with debugging symbols.
The reason I was recreating QNetworkAccessManager is because I was under the impression that I needed to do so when I lost network access (m_mgr->networkAccessible() != QNetworkAccessManager::Accessible). That's what a user said on this stack overflow post. Is that incorrect? If I could just used something like setNetworkAccessible() that would avoid this whole mess. I've tested out removing the QNAM deletion and the exception does not occur.
I guess I am sort of confused in general about what QNetworkAccessManager::NetworkAccessibility even represents? It's not going to alter the actual network state, NetworkManager handles that
This was added to detect memory leaks and report them when the application quits. After removing this, the excessive "memory leak" was gone.
I am assuming that the address sanitizer allocates memory for each allocation done by the application, for its own administration purposes. I suspect that when the application releases the allocated memory, the sanitizer holds on to the respective administration data until the application quits. This could explain why when I remove the sanitizer it also removes the leak.