How to free memory after Gio::SocketClient::create()

I’m using giomm wrapper for browser page updates. As browser supports multiple protocols, I’m creating new SocketClient type configuration on every page reload (according to current page URI scheme).

The object of SocketClient stored in class private member, because it wanted for async operations. How can I properly make this object clean (or nullptr) on page update completed?

I do following construction to close Gio::SocketConnection on every page update action begin and async request finish, but what about Gio::SocketClient?

// Close previous socket connection (on active)
if (socket__connection->is_connected())
{
    socket__connection->close();
}

// Make new socket connection for new protocol..

Gio::SocketClient::create() returns a Glib::RefPtr<Gio::SocketClient>.
Glib::RefPtr is an alias for std::shared_ptr. You can use std::shared_ptr::reset().
For instance, if you have a class member socket_client:

socket_client.reset();
1 Like