近期在项目中使用文字转语音遇到一个小问题。项目中是在service中持有一个 TextToSpeech对象,通过messenger与service通信进行文字转语音的操作。但是每次推出应用不久就出出现内存泄漏的问题,如下:
Service com.lucis.workout.service.PrivateSoundService has leaked ServiceConnection android.speech.tts.TextToSpeech$Connection@bf84811 that was originally bound here
android.app.ServiceConnectionLeaked: Service com.lucis.workout.service.PrivateSoundService has leaked ServiceConnection android.speech.tts.TextToSpeech$Connection@bf84811 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1344)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1239)
at android.app.ContextImpl.bindServ