I don't really instantiate an AndroidHttpClient anywhere in my code, but I do start a recognizer intent, which yields this exception at some point when my application runs:
Leak found
java.lang.IllegalStateException: AndroidHttpClient created and never closed
at android.net.http.AndroidHttpClient.<init>(AndroidHttpClient.java:152)
at android.net.http.AndroidHttpClient.newInstance(AndroidHttpClient.java:138)
at com.google.android.voicesearch.speechservice.SpeechServiceHttpClient.<init>(SpeechServiceHttpClient.java:59)
at com.google.android.voicesearch.speechservice.ServerConnectorImpl.<init>(ServerConnectorImpl.java:85)
at com.google.android.voicesearch.VoiceSearchContainerImpl.createRecognitionController(VoiceSearchContainerImpl.java:83)
at com.google.android.voicesearch.GoogleRecognitionService.onCreate(GoogleRecognitionService.java:65)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2066)
at android.app.ActivityThread.access$2500(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
Assuming the bug is not in Android's code but in mine, this leaked resource could have been created only in one of the following:
SpeechRecognizer.createSpeechRecognizer()
new RecognitionListener()
new Intent(SpeechRecognizer.RESULTS_RECOGNITION)
SpeechRecognizer.startListening(recognizerIntent)
But how do I know which one?
Assuming the bug is not in Android's code but in mine
The leak is in com.google.android.voicesearch
, which is not your code.
If you can create a small sample project that demonstrates this leak, we can get an issue over to Google and hope that they will address it.
Why do you assume it's not in Android? SpeechRecognizer
and RecognitionListener
are in ASOP, so you can check (it's not there). Most probably SpeechServiceHttpClient
uses an AndroidHttpClient
internally. There is not much you can do but check you are calling all finalizer methods, if any (close(), shutdown(), etc), of the framework classes you are using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With