У меня есть UDP-клиент, который общается с локальным сервером (они подключены по WiFi). Пока клиент не подключен к WiFi, через 2-3 минуты приложение зависало и закрывалось. Сервер отправляет 100 данных в секунду, и клиент должен их обработать. О чем говорит эта ошибка? : /
A/.example.new_u: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI IsInstanceOf called with pending exception java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
java_vm_ext.cc:542] at void java.lang.Thread.nativeCreate(java.lang.Thread, long, boolean) (Thread.java:-2)
java_vm_ext.cc:542] at void java.lang.Thread.start() (Thread.java:733)
java_vm_ext.cc:542] at boolean java.util.concurrent.ThreadPoolExecutor.addWorker(java.lang.Runnable, boolean) (ThreadPoolExecutor.java:975)
java_vm_ext.cc:542] at void java.util.concurrent.ThreadPoolExecutor.execute(java.lang.Runnable) (ThreadPoolExecutor.java:1382)
java_vm_ext.cc:542] at android.os.AsyncTask android.os.AsyncTask.executeOnExecutor(java.util.concurrent.Executor, java.lang.Object[]) (AsyncTask.java:651)
java_vm_ext.cc:542] at void com.example.new_ui.UDPClient.sendData(java.lang.String) (UDPClient.java:109)
java_vm_ext.cc:542] at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:873)
A/.example.new_u: java_vm_ext.cc:542] at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
java_vm_ext.cc:542] at void android.os.Looper.loop() (Looper.java:214)
java_vm_ext.cc:542] at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7099)
java_vm_ext.cc:542] at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
java_vm_ext.cc:542] at void com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run() (RuntimeInit.java:494)
java_vm_ext.cc:542] at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:965)
java_vm_ext.cc:542]
java_vm_ext.cc:542] in call to IsInstanceOf
java_vm_ext.cc:542] "main" prio=5 tid=1 Runnable
java_vm_ext.cc:542] | group="main" sCount=0 dsCount=0 flags=0 obj=0x74af4580 self=0xe53f9000
java_vm_ext.cc:542] | sysTid=16852 nice=-10 cgrp=default sched=0/0 handle=0xe9a324a8
java_vm_ext.cc:542] | state=R schedstat=( 66493105489 8184827556 44456 ) utm=4845 stm=1803 core=4 HZ=100
java_vm_ext.cc:542] | stack=0xff42b000-0xff42d000 stackSize=8MB
java_vm_ext.cc:542] | held mutexes= "thread list lock" "mutator lock"(shared held)
java_vm_ext.cc:542] native: #00 pc 002e5b93 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #01 pc 0038014d /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #02 pc 0037c70b /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #03 pc 00239cff /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #04 pc 0023a067 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #05 pc 000c58a7 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #06 pc 000c4549 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #07 pc 000c3a2b /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #08 pc 000b7bb5 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #09 pc 00061a65 /system/lib/libopenjdkjvmti.so (openjdkjvmti::ThreadUtil::GetThreadInfo(_jvmtiEnv*, _jobject*, _jvmtiThreadInfo*)+512)
java_vm_ext.cc:542] native: #10 pc 00038b13 /data/data/com.example.new_ui/code_cache/libjvmtiagent_arm.so (???)
java_vm_ext.cc:542] native: #11 pc 00038a59 /data/data/com.example.new_ui/code_cache/libjvmtiagent_arm.so (???)
java_vm_ext.cc:542] native: #12 pc 00037d79 /data/data/com.example.new_ui/code_cache/libjvmtiagent_arm.so (???)
java_vm_ext.cc:542] native: #13 pc 003854e1 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #14 pc 0039581b /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #15 pc 0035dde7 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #16 pc 0023f207 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #17 pc 000cf511 /system/lib/libart.so (???)
java_vm_ext.cc:542] native: #18 pc 000737fb /system/lib/libandroid_runtime.so (???)
java_vm_ext.cc:542] native: #19 pc 00002f15 /system/bin/app_process32 (???)
A/.example.new_u: java_vm_ext.cc:542] native: #20 pc 0008de6d /system/lib/libc.so (__libc_init+48)
java_vm_ext.cc:542] native: #21 pc 00002bfd /system/bin/app_process32 (???)
java_vm_ext.cc:542] native: #22 pc 00000306 <anonymous:e9a2f000> (???)
java_vm_ext.cc:542] (no managed stack frames)
java_vm_ext.cc:542]
W/.example.new_u: it should skip dumping thread list to prevent deadlock: exclusive owner ->16852
Строка, упомянутая в журнале ошибок, такова:
asyncClient.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Эта строка в этой функции отправляет данные на сервер:
void sendData(String data){
message = data;
AsyncTask<Void, Void, Void> asyncClient = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
DatagramPacket dp;
dp = new DatagramPacket(message.getBytes(), message.length(), host, portNumber);
ds.send(dp);
if (!receiveCalled) {
ReceiveData();
}
} catch (Exception e) {
dataIsOK = false;
} finally {
if (ds != null) {
// ds.close();
}
}
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
};
asyncClient.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Кто-нибудь знает, почему это произошло?