• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Garbage Collector is crashing with "null pointer dereference" on physics object!

clee2005

Member
From GMS 2.3.1 runtime release notes:
In-Game: Some projects crash silently when changing rooms if garbage collector is enabled

Apparently it is fixed.
:)
Thanks for all your posts and details about the GC crashing... that information is invaluable and saved me a lot of time!

I ended up using the 2.3.1 beta and putting out one of our games to test the waters with it. I'm seeing a lot of errors in the Google Play Console :

GML:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> com.donkeysoft.wordwowfree <<<

backtrace:
  #00  pc 0000000000000004  <unknown>
  #00  pc 000000000010b98c  /data/app/com.donkeysoft.wordwowfree-1/lib/arm/libyoyo.so (MarkAndSweepGen(int, int, bool)+2116)
  #00  pc 000000000010d17c  /data/app/com.donkeysoft.wordwowfree-1/lib/arm/libyoyo.so (DoGenerationalGC(int)+332)
  #00  pc 000000000025b240  /data/app/com.donkeysoft.wordwowfree-1/lib/arm/libyoyo.so (DoAStep()+1236)
  #00  pc 000000000025b990  /data/app/com.donkeysoft.wordwowfree-1/lib/arm/libyoyo.so (MainLoop_Process()+1392)
  #00  pc 000000000037bb3c  /data/app/com.donkeysoft.wordwowfree-1/lib/arm/libyoyo.so (Java_com_yoyogames_runner_RunnerJNILib_Process+1016)
  #00  pc 000000000219db6b  /data/app/com.donkeysoft.wordwowfree-1/oat/arm/base.odex (offset 0x2143000)
Unfortunately, there are no details above the MarkAndSweepGen that can help point to where it might be crashing. I know @SnoutUp had the same issues with 2.3.0. Just wondering if anyone had any insight on these. Maybe they are still caused from the instance_destroy() in the room end events (I still have that in my code as I read all your posts after releasing this version to Google Play).
 

Tornado

Member
If this is of any help to you, we disabled GC
gc_enable(false);
and are calling
gc_collect();
only on dedicated placed when we consider it to be safe.

Also we removed all instance_destroy() from all Room End Events.
We done all of this already in 2.3.0.

I saw in release notes for 2.3.1 that they have fixed something, I tried quickly the old code with 2.3.1, it seems that the issue with instance_destroy() is fixed.
Also the demo project which I submitted to Yoyo doesn't crash in 2.3.1.

But this was only one problem with crashing the GC, as you already mentioned SnoutUp and other users had also GC crashes but without having instance_destroy() in the Room Events.

I hope this can help at least a little.
 
Last edited:

clee2005

Member
Awesome @Tornado ! Thanks very much. I'll try the manual gc_collect() and see if that brings down the exceptions that I'm seeing, and remove the instance_destroy commands from the room_end.

Much appreciated!
 

SnoutUp

Member
Awesome @Tornado ! Thanks very much. I'll try the manual gc_collect() and see if that brings down the exceptions that I'm seeing, and remove the instance_destroy commands from the room_end.
Much appreciated!
Please report on how it affects stability of the game. I also plan to try the manual gc_collect() out, but might take a while.
 

Mool

Member
At all android GMS Devs. Would it be possible to create a (discord?) group? I am really looking for other android gms devs, where we can discuss bugs, ANR´s, crashes, extensions, etc.

I also have some good extensions i could share.



Right now I struggle with this ANR


at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:442)
at java.lang.Object.wait (Object.java:568)
at android.opengl.GLSurfaceView$GLThread.onPause (GLSurfaceView.java:1725)
at android.opengl.GLSurfaceView.onPause (GLSurfaceView.java:579)
at com.gaming_apps.water_physics_simulation.RunnerActivity.onPause (RunnerActivity.java:849)
at android.app.Activity.performPause (Activity.java:8144)
at android.app.Instrumentation.callActivityOnPause (Instrumentation.java:1508)
at android.app.ActivityThread.performPauseActivityIfNeeded (ActivityThread.java:4947)
at android.app.ActivityThread.performPauseActivity (ActivityThread.java:4908)
at android.app.ActivityThread.handlePauseActivity (ActivityThread.java:4860)
at android.app.servertransaction.PauseActivityItem.execute (PauseActivityItem.java:46)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2261)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:237)
at android.app.ActivityThread.main (ActivityThread.java:8107)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)

 

Mool

Member
I fixed the garbage collector crashes:

All you need to do is:

1. disable garbage collector
2. do gc_collect() manually all 6 steps, but before u call gc_collect() u need to log gc_get_stats() to see how much garbage exists. !!!!!The goal is to make the garbage small as possible, bacause if there is more work for the garbage collector, then it also means there can be a crash!!!!
3. Startup the debugger and go into a "level" of your game, where a lot is going on.
4. Start the profiler and select bottom up as sorting
5. Look for @@NewGMLArray@@ or other garbage creating things (see @Nocturne post in this thread)
--> 6. Now you know which code sections of your game create a lot of garbage, for me it was for example:

STEP Event: variable1 = [abc, def, ghi];

--> I changed it to:
variable1[0] = abc;
variable1[1] = def;
variable1[2] = ghi;

to avoid creating a new GML Array every step.

7. check if your change was fine by checking gc_get_stats(). This should now be smaller (num_objects_in_generation)
 
Top