# Service manager lifetime and ownership in Unreal; best practice.

**URL:** <https://forums.unrealengine.com/t/service-manager-lifetime-and-ownership-in-unreal-best-practice/499250>\
**Category:** C++\
**Tags:** subsystem, unreal-engine\
**Created:** [February 17, 2022, 6:24pm UTC](https://forums.unrealengine.com/t/service-manager-lifetime-and-ownership-in-unreal-best-practice/499250 "2022-02-17T18:24:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZStaSmith](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZStaSmith](https://forums.unrealengine.com/u/ZStaSmith)\
**Post date:** [February 17, 2022, 6:24pm UTC](https://forums.unrealengine.com/t/service-manager-lifetime-and-ownership-in-unreal-best-practice/499250/1 "2022-02-17T18:24:51Z")

</div>

We are currently using a GameInstanceSubsystem to manage the lifetime and accessibility of a C++ service management class instance (read: shared\_ptr object) from a pure C++ library. This binds the lifetime of the object to that of the GameInstanceSubsystem. We are also taking advantage of getting the subsystem via a game instance’s GetSubsystem, so that we get that sort of singleton, global, access of that subsystem that own’s our object.  
We would like to move the lifetime of the GameInstanceSubsystem’s object, our instance of our class, to an earlier initialization.

Our new solution is to, instead, is to inherit directly from the UObject class, then this allows us to instantiate that UObject anywhere, even dynamically in blueprints.

But I was wondering if there is a more elegant way to do this?

---

<div class="post-metadata">

**Author:** ![eblade](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eblade](https://forums.unrealengine.com/u/eblade)\
**Post date:** [February 17, 2022, 9:46pm UTC](https://forums.unrealengine.com/t/service-manager-lifetime-and-ownership-in-unreal-best-practice/499250/2 "2022-02-17T21:46:04Z")

</div>

you could go with an Engine subsystem? I think it’s called?

---

<div class="post-metadata">

**Author:** ![ZStaSmith](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZStaSmith](https://forums.unrealengine.com/u/ZStaSmith)\
**Post date:** [February 28, 2022, 7:39pm UTC](https://forums.unrealengine.com/t/service-manager-lifetime-and-ownership-in-unreal-best-practice/499250/3 "2022-02-28T19:39:46Z")

</div>

This is a strong consideration. Thanks!
