Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My game stop to free memory in android devices with strange logcat #35424

Closed
fian46 opened this issue Jan 22, 2020 · 3 comments
Closed

My game stop to free memory in android devices with strange logcat #35424

fian46 opened this issue Jan 22, 2020 · 3 comments
Labels

Comments

@fian46
Copy link

fian46 commented Jan 22, 2020

**Godot version:**3.1.1

OS/device including version: android 9

Issue description: my game work fine in linux but in android sometimes it stop freeing memory. when i connect to adb and watch the logcat this is the output :

01-19 17:23:40.986 12529 12529 F DEBUG : #00 pc 0000000000274160 /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #1 pc 0000000000274958 /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #2 pc 0000000000249278 /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #3 pc 000000000025601c /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #4 pc 0000000001740930 /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #5 pc 00000000001df13c /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so
01-19 17:23:40.986 12529 12529 F DEBUG : #6 pc 00000000001a8930 /data/app/com.btree-WmPXEDYCjQ4JJaLWUlgpLQ==/lib/arm64/libgodot_android.so (Java_org_godotengine_godot_GodotLib_step+168)
01-19 17:23:40.986 12529 12529 F DEBUG : #8 pc 00000000000084f0 /dev/ashmem/dalvik-jit-code-cache (deleted) (org.godotengine.godot.GodotView$Renderer.onDrawFrame+48)
01-19 19:32:12.108 7152 7152 F DEBUG : #2 pc 00000000018da21c /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #3 pc 000000000173e534 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #4 pc 000000000173e314 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #5 pc 00000000002a6654 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #6 pc 00000000016e32b8 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #7 pc 000000000179be10 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #8 pc 000000000029858c /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #9 pc 00000000002543d4 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #10 pc 00000000008b4038 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #11 pc 0000000000e145f4 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #12 pc 00000000016dfc48 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #13 pc 00000000008e8d30 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #14 pc 00000000008e918c /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #15 pc 00000000001def78 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so
01-19 19:32:12.108 7152 7152 F DEBUG : #16 pc 00000000001a8930 /data/app/com.btree-DA2whjDXcf_tglZzL2oDeg==/lib/arm64/libgodot_android.so (Java_org_godotengine_godot_GodotLib_step+168)
01-19 19:32:12.108 7152 7152 F DEBUG : #18 pc 000000000000b180 /dev/ashmem/dalvik-jit-code-cache (deleted) (org.godotengine.godot.GodotView$Renderer.onDrawFrame+48)

at this point my game memory keep increasing and calling Object.free() is pointless.

Steps to reproduce: i am not sure, it happened "sometimes"

Minimal reproduction project:

@bluwork
Copy link

bluwork commented Jan 22, 2020

Godot can help you to catch leaks.

Screenshot 2020-01-22 at 12 48 06

In the bottom of editor choose Debugger > Monitors and, from the left side, check all below Object:

Screenshot 2020-01-22 at 12 55 31

Start game from editor and monitor these values.

Screenshot 2020-01-22 at 13 10 00

If these values oscillate and, after some time, your graph looks like EKG(ECG), everything is good (probably).

Screenshot 2020-01-22 at 13 14 10

If one or more of the values always increase, game have a leak.

Some of the common reasons:

Instantiating node (by calling your_node.new() or by instantiating a PackedScene (your_packed_scene.instantiate()) an not adding it to the tree( using addChild()) will make orphan node. It must be cleared manually by calling queue_free() or free(), because it not have parent.

Similarly, if some node is removed by calling removeChild(), it become orphan node. It must be cleared manually (queue_free() or free()), or to be "readded" to tree.

If you need only a script, but you not need a node, you can always extends Reference (or just remove extends Node or similar from your script). References are released when no longer in use.

@fian46
Copy link
Author

fian46 commented Jan 22, 2020

i completely understand the memory management reference counting and object. yes the object and node count is keep increasing in debugger. but the problem start when above logcat is printed in adb. worth mentioning that as soon as it happened the debugger is disconnected. adb is also disconnected. and when use adb again when the game is running that same logcat is printed and adb is disconnected again. i am not sure why.

my question is is it save to call Object.free() from a thread ?
in my linux mint machine it always working fine and no leak is detected in debugger.

@bluwork
Copy link

bluwork commented Jan 22, 2020

Have you tried it with another device or emulator (to exclude a specific device)?
Did you tried node.call_deferred("free")? (https://docs.godotengine.org/en/3.1/tutorials/threads/thread_safe_apis.html#scene-tree)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants