# STEAM\_CALLBACK\_MANUAL being deleted by Garbage Collection

**URL:** <https://forums.unrealengine.com/t/steam_callback_manual-being-deleted-by-garbage-collection/475272>\
**Category:** Platform & Builds\
**Tags:** garbage-collector, steamworks, Steam, garbage-collection, unreal-engine, question\
**Created:** [December 1, 2020, 2:00pm UTC](https://forums.unrealengine.com/t/steam_callback_manual-being-deleted-by-garbage-collection/475272 "2020-12-01T14:00:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Hogan23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Joe\_Hogan23](https://forums.unrealengine.com/u/Joe_Hogan23)\
**Post date:** [December 1, 2020, 2:00pm UTC](https://forums.unrealengine.com/t/steam_callback_manual-being-deleted-by-garbage-collection/475272/1 "2020-12-01T14:00:07Z")

</div>

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();
}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b7505e2e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b7505e2e](https://forums.unrealengine.com/u/anonymous_user_b7505e2e)\
**Post date:** [December 2, 2020, 2:35pm UTC](https://forums.unrealengine.com/t/steam_callback_manual-being-deleted-by-garbage-collection/475272/2 "2020-12-02T14:35:57Z")

</div>

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,
