游戏加载过程中崩溃:了解“为...保留的JNI关键锁”

时间:2019-03-12 09:23:03

标签: java android libgdx

我的LibGDX And​​roid游戏在加载期间随机崩溃。我猜这与Android杀死我的应用有关,这是因为主线程中的任务长时间运行或存在内存问题。

在这方面,我想了解我的日志中这些行的含义:

03-12 10:00:18.444  5522  5540 W com.asdfasdf: JNI critical lock held for 38.485ms on Thread[13,tid=5540,Runnable,Thread*=0x9d711000,peer=0xa3e40000,"GLThread 248"]
03-12 10:00:18.498  5522  5540 W com.asdfasdf: JNI critical lock held for 18.423ms on Thread[13,tid=5540,Runnable,Thread*=0x9d711000,peer=0xa3e40000,"GLThread 248"]
03-12 10:00:20.236  5522  5540 W com.asdfasdf: JNI critical lock held for 136.530ms on Thread[13,tid=5540,Runnable,Thread*=0x9d711000,peer=0xa3e40000,"GLThread 248"]
03-12 10:00:20.321  5522  5540 W com.asdfasdf: JNI critical lock held for 59.744ms on Thread[13,tid=5540,Runnable,Thread*=0x9d711000,peer=0xa3e40000,"GLThread 248"]
03-12 10:00:20.700  5522  5540 W com.asdfasdf: JNI critical lock held for 49.684ms on Thread[13,tid=5540,Runnable,Thread*=0x9d711000,peer=0xa3e40000,"GLThread 248"]

我在这个话题上找不到很多。日志行被分类为警告,但是我不太确定他们想告诉我什么。

然后,游戏结束于这些行,并向我提供了一个墓碑(欢呼。):

03-12 10:00:27.631  5522  5532 F libc    : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 5532 (FinalizerDaemon), pid 5522 (com.asdfasdfe)
03-12 10:00:27.839  5618  5618 F DEBUG   : pid: 5522, tid: 5532, name: FinalizerDaemon  >>> com.asdfasdfe <<<
03-12 10:00:28.769  1944  5625 W ActivityManager:   Force finishing activity com.asdfasdfe/.AndroidLauncher
03-12 10:00:28.809  1944  2026 W InputDispatcher: channel '5f19156 com.asdfasdfe/com.asdfasdfe.AndroidLauncher (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
03-12 10:00:28.810  1944  2026 E InputDispatcher: channel '5f19156 com.asdfasdfe/com.asdfasdfe.AndroidLauncher (server)' ~ Channel is unrecoverably broken and will be disposed!

1 个答案:

答案 0 :(得分:1)

您的一个内部库中有一个占用大量内存的操作。进行跟踪以查找哪个库正在使用内存进行读/写操作或后台任务。为了解决该问题,您可能需要增加缓冲区并添加一些检查以防止过多的内存分配。