utopia-rise / godot-kotlin-jvm

Godot Kotlin JVM Module
MIT License
560 stars 38 forks source link

Why the member method without RegisterFunction annotation will leak when game exit? #650

Closed BryanSer closed 1 month ago

BryanSer commented 1 month ago

image When i remove the @RegisterFunction annotation. After game exit, will show jvm leak dialog:

image

playerBackpack is a node.

piiertho commented 1 month ago

Hello ! Since playerBackpack is a Node, you have to free it manually. Do you free it ?

BryanSer commented 1 month ago

Hello ! Since playerBackpack is a Node, you have to free it manually. Do you free it ?

Thanks for you reply. I have not free playerBackpack. playerBackpack is get by getNodeAs(), i think it will be free by parent. Why doesn't the leak warning pop up after I added the @RegisterFunction annotation?

CedNaru commented 1 month ago

How do you call this method ? It should be totally fine (or at least I don't see any reason for a leak) if you call it only from another Kotlin code. But do you maybe try to use it from GDSCript or even as the callable for a signal ? In such case, if you don't register it, the method call will fail, trigger an error and probably prevent other code to be executed (code that might be freeing some stuff).

Do you have any logs to share that would show some warning/error ? Or at least the list of leaked instances, that one should be pinted do your console.

BryanSer commented 1 month ago

How do you call this method ? It should be totally fine (or at least I don't see any reason for a leak) if you call it only from another Kotlin code. But do you maybe try to use it from GDSCript or even as the callable for a signal ? In such case, if you don't register it, the method call will fail, trigger an error and probably prevent other code to be executed (code that might be freeing some stuff).

Do you have any logs to share that would show some warning/error ? Or at least the list of leaked instances, that one should be pinted do your console.

I called it from _input method. I retested it, and it's strange that this issue doesn't exist on another device. The purpose of my issue is to understand the essential reasons behind this behavior, which currently seems to be caused by a specific operating environment. Thanks for your reply.Now we can stop paying attention to this issue until I can encounter it stably.