koreader / android-luajit-launcher

Android NativeActivity based launcher for LuaJIT, implementing the main loop within Lua land via FFI
MIT License
132 stars 84 forks source link

内存泄漏隐患? #429

Closed izxyz closed 1 year ago

izxyz commented 1 year ago

native层没有看到lua层对jni调用统计的代码, 那么在lua虚拟机异常停止后, 在lua层比如self.env[0]FindClass申请到的内存会不会得不到释放从而导致泄漏?

pazos commented 1 year ago

The code path on a error/crash is in https://github.com/koreader/android-luajit-launcher/blob/master/jni/main.c#L205-L208

We finish the NativeActivity, which is the proper thing to do. Albeit the framework will do it for us in case we don't exist cleanly, but that shouldn't happen.

Finishing the nativeActivity makes the zygote forked process where the app lives to be killed, so no memory leaks are possible here, until I miss something.

Do you have a test case that shows how an anormal exist would lead to memory leaks?

izxyz commented 1 year ago

现在只是我的假想, 我还没有运行起来.因为在我的设备上无法运行 华为p30pro hoarmonyOS3.0 9404fc483a0b7d67ac7855b7c70909c

pazos commented 1 year ago

Yes. The app is just a shell. You need to add lua code to make it work. Have a look at examples/hello world