[每次我使用AVSpeechSynthesizer说话时,Instruments都会在AXSpeechImplementation库中报告内存泄漏。这是我用来拨打电话的代码:
AVSpeechUtterance *speak = [AVSpeechUtterance speechUtteranceWithString:text];
speak.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
speak.rate = AVSpeechUtteranceMaximumSpeechRate * .2;
[m_speechSynth speakUtterance:speak];
这里是Instruments屏幕截图的链接http://imageshack.com/a/img690/7993/b9w5.png
对于它的价值-是的,我发现语音合成器在每次发声时都会看到完全相同的16byte泄漏。因此,要么是苹果代码泄漏,要么我们都在某个地方犯了同样的错误!
Ali
我通过将AVSpeechSynthesizer声明为全局变量来解决此问题
static let synth = AVSpeechSynthesizer()