Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Bug] Game Singleton and UObject

I have a use case that generates a crash in editor, and makes the development a living hell. This was working fine in 4.10 and after upgrade to 4.12, singleton related issues started to appear.

Currently, I'm keeping a few objects in a singleton class for easy access for the data I want to keep in memory for the entire game life. This includes a custom created TCP socket, and data containing TArrays and C arrays... nothing fancy.

The problem occures when the validity of the objects are checked. In editor, on game start, a custom "blueprint function library" static func creates the required items, initializes, etc. If these already init (or is valid) function does nothing, and uses available items. If you stop the game in editor, and restart again a bunch of different errors start to appear. One is about an IsValid call (main thread does not even make a call to my classes, just crashes). Sometimes it's about UObject not valid or TArray index is out of bounds... etc...

I found out that, the created singleton lives as long as the editor is on. However this have been different in previous versions. Singleton was destroyed when in-editor game test was ended.

Now, even though the singleton is not destroyed, it seems that it is not valid or the memory address is not readable (already released maybe?) and editor crashes.

I've created a sample project and wrote a few C++ classes to demonstrate what is going on. I can re-create the conditions on different windows machines so I believe this is a UE editor bug. The calls are directly in the level blueprint. It doesn't matter if you move it to another actor/pawn/etc blueprint, same problem occurs. You can download the project for testing from:


And here is the thread crash log from the crash reporter: CRASH LOG

Product Version: UE 4.12
crash.txt (4.9 kB)
more ▼

asked Jun 22 '16 at 09:10 AM in C++ Programming

avatar image

168 13 15 21

avatar image emrahgunduz Jun 22 '16 at 09:16 AM
crash2.txt (4.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

So, UE is garbage collecting all c++ uobjects, even if the object's pointer is set in the game singleton object. Singleton is not destroyed, but everyting that is referenced from it is. So crashes on IsValid...

However, if I make the singleton blueprintable, and create a bp, set this as the singleton class of game, the references no longer get destroyed...

Yet, still, the singleton continues to exist even though the test has ended in editor. So, my TCP socket object is not destroyed, and connection remains open.

Not what I had in mind. Currently it works.

I also do not know if the singleton must be destroyed or not when editor test ends. In some cases, it is not desirable to let the objects live in memory, but in some, it might help you test multiple levels while data lives on... so exhausting to choose :)

more ▼

answered Jun 24 '16 at 02:21 PM

avatar image

168 13 15 21

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question