# Create UObject in StartupModule()

**URL:** <https://forums.unrealengine.com/t/create-uobject-in-startupmodule/409683>\
**Category:** Plugins\
**Tags:** uobject, unreal-engine, Plugins, CPP, question\
**Created:** [November 15, 2017, 10:37am UTC](https://forums.unrealengine.com/t/create-uobject-in-startupmodule/409683 "2017-11-15T10:37:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [November 15, 2017, 8:05pm UTC](https://forums.unrealengine.com/t/create-uobject-in-startupmodule/409683/3 "2017-11-15T20:05:05Z")

</div>

Most likely because it gets garbage collected as engine don’t see it referenced anywhere (aka used anywhere) as you not using UPROPERTY() and treats it as trash, as you can’t use those in module class or any other unrefected classes you should use TWeakObjectPtr so you wont get invalid pointer like you have now

Read this how to keep your UObject alive (thru it might be little bit outdated):

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

---

_[View the full topic](https://forums.unrealengine.com/t/create-uobject-in-startupmodule/409683)._
