Why is calling Process.killProcess(Process.myPid()) a bad idea?

前端 未结 6 1794
我寻月下人不归
我寻月下人不归 2020-12-01 06:55

I\'ve read some posts stating that using this method is \"not good\", shouldn\'t be used, it\'s not the right way to \"close\" the application and it\'s not how Android work

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 07:03

    Well, Unit3d is most probably using native code, and they are killing the process as an insurance -- they don't want to leak memory. You could argue whether this is a good idea or not, but the fact that they used it does not mean that you should too.

    Maybe there are some extreme cases where you would want to use killProcess(), but usually the OS does this for you, according to current load and usage. Not sure what kind of an answer you are looking for -- you are aware that using killProcess() might break things, unless you can justify its usage, don't use it.

提交回复
热议问题