Garbage collection crashes not caused directly by the editor

I’m Using Unreal 4.8.2, And my game won’t crash when play in Editor, But will crash when running on Android after a while.

The reason is I put a class member pointer without UPROPERTY() in my Actor, when running after a while, the pointer is garbage collection. It will not crashes By Editor but crash when running on mobile, So I Don’t know why until I review my code line by line.

My Question is :

  1. I wonder why the editor don’t crash, I think if it will crash on Android it should also crash on Editor, otherwise it’s vary hard to debug.

  2. What should I do when my game running well but crash on Mobile, it’s hard to debug with this, since I don’t know any infomation, the ant log don’t log anything about garbage collection crash.

  3. Is there any good way to get stacktrace when my game crash on mobile?

1 - In the Editor you working with PC: huge, powerful machine. Android device is weak. Rarely code depends on perfomance, what is bad. If perfomance low, chance of crash is higher. It is like using delay to wait for resource to load, there is PC fast enough to load this before time is out, but Android is not, and verification were forgotten.
2 and 3 - Use ADB to get log. In folder [ADB_Location]\platform-tools (where adb.exe located) create .bat file with this text:
adb logcat -d > [Where you want to place log]\AndroidLog.txt
You need to execute .bat file right after crash on your device. Device should be connected via USB and “USB Debugging” in developer options must be turned on. It will give log for last 4-5 seconds in about 1000 lines (for my device it is actually that). You need to find name of your app somewhere there and watch closely where is error described.
Just in case, some tips with GC:
No custom destructors for UObject allowed, if they work at least one, it will cause crash 100%.
No manual control for UPROPERTY() pointers. Try to avoid using “new” operator. Don’t ever use “delete”, if you want free resources you need to equate this pointer to NULL (or nullptr, or 0), GC will purge resources automaticaly.

Hey,

With the logs mentioned by HungryDoodles if you can obtain them and cannot figure out how to read them, please upload them to this post and we will look over the issue and see what’s causing the crash.

Thank you! :slight_smile:

Thanks for the answer, but it did not solve my problem.

2 and 3 , I already use logcat, but it dit not log anything about Garbage collection.

I finally use googlebreakpad to find the reason. It turns out that some team members forgot to write UPROPERTY() with a class member (let’s say A), so when the game running on mobile, the garbage collection collected A, and when somewhere use A again, game crashes.we use NewObject() method to dynamic create object, never use “new” operater in UE4,

Sorry for my poor English, I realize that code may show my case more clear.

 class UMyObjManager : public UObject
 {
            ..................
             some code here
         ................
 };
     
 class AMyCharacter : public ACharacter
 {
 private:
         class UMyObjManager* MyManager;
 
 public:
         class UMyObjectManager* GetManager()
         {  
            if(MyManager == nullptr )
            {
                MyManager = NewObject<UMyObjManager >(this);
             }
              return MyManger; 
          }
     
 };     

I found that it crash because someone didn’t write UPROPERTY() on this line

 class UMyObjManager* MyManager;

it should be

 UPROPERTY()
 class UMyObjManager* MyManager;

When I use UE 4.7.6, the editor will crash, and I can found the error easy. But When I Update the editor to UE 4.8.2, it is not crash anymore untile I launch my game on mobile. Why these editors behave different? There are so many people in our development team, we have to find out a way to prevent bugs like this happen again. Debugging a garbage collection crashes is very hard in UE4 now.

I notice that in UE4.8.1 hotfix, have a fix that:

UE-11816 [CrashReport] Garbage collection crashes not caused directly by the editor

What does it mean?

Do you have more easier way to debug something like garbage collection crash?

Thanks in advance.

In order to assist you further, I need you to upload the crash logs from 4.8.2 or 4.8.3 as a .txt file to your next reply. Without seeing the full log, we will not be able to tell you exactly what’s causing the issue.

Thank you.

Hey,

I have not heard from you in quite a few days and for that reason, I must close this AnswerHub question. However, if you have any further questions or concerns, please reply back and we’ll be more than happy to assist you further.

Thank you and have a nice day!