STEAM_CALLBACK_MANUAL being deleted by Garbage Collection

I’m implementing some Steam API callbacks, manually because the automated STEAM_CALLBACK is triggering twice. The STEAM_CALLBACK_MANUAL is only calling once when registering a function, but it is removed after about 30 seconds by GC. I tried putting in a wrapper class, same results. In the functions, the logout shows it is firing until it is deleted. I tried SharedPtr as well without using the macro. I just need to know how to prevent

Declaration and assignment code:

SteamworksGIS.h

	STEAM_CALLBACK_MANUAL(USteamworksGIS, OnFriendLobbyUpdate, LobbyChatUpdate_t, OnFriendLobbyUpdateCallback);
	STEAM_CALLBACK_MANUAL(USteamworksGIS, OnJoinLobbyRequested, GameLobbyJoinRequested_t, OnJoinLobbyRequestedCallback);
	STEAM_CALLBACK_MANUAL( USteamworksGIS, OnPersonaStateChange, PersonaStateChange_t, OnPersonaStateChangeCallback);

SteamworksGIS.cpp

USteamworksGIS::USteamworksGIS() {
	OnFriendLobbyUpdateCallback.Register(this, &USteamworksGIS::OnFriendLobbyUpdate);
	OnJoinLobbyRequestedCallback.Register(this, &USteamworksGIS::OnJoinLobbyRequested);
	OnPersonaStateChangeCallback.Register(this, &USteamworksGIS::OnPersonaStateChange);
}

USteamworksGIS::~USteamworksGIS()
{
	OnFriendLobbyUpdateCallback.Unregister();
	OnJoinLobbyRequestedCallback.Unregister();
	OnPersonaStateChangeCallback.Unregister();
}
1 Like

Dear valued Unreal Engine user,

It looks as though the STEAM_CALLBACK_MANUAL is just to define the delegate and the callback function. So should not specifically contain any UObject derived classes that can be Garbage Collected.

Perhaps are you referring to the USteamworksGIS class itself being garbage collected? This would then call the destructor ~USteamworksGIS and un-register the callbacks.

If this is the case, then the code in question will be wherever a USteamworksGIS object is declared, not within the USteamworksGIS class itself. It may be that point is where you need to define it as a SharedPtr or as a UPROPERTY, or that other class is also being destroyed and garbage collected rather than USteamworksGIS.

Thank you for your continued support,