Memory Growth with PhraseListGrammar
See original GitHub issueDescribe the bug We’ve seen process RSS memory continually grow when using the speech-sdk for continuous recognition. I’ve been able to reproduce this when adding phrases to the PhraseListGrammar in a minimal reproduction below (updating the <subscription_key> value). From my testing, 1 phrase seems to be enough but the more phrases added the greater the growth. We’re wondering if there is something wrong in this implementation to reclaim that memory or if there is an issue in the centos7 native libraries.
To Reproduce
public static void main(String[] args) throws InterruptedException, ExecutionException {
System.loadLibrary("Microsoft.CognitiveServices.Speech.java.bindings");
while(true) {
// create resources
SpeechConfig speechConfig = SpeechConfig.fromSubscription("<subscription_key>", "EastUS");
speechConfig.setSpeechRecognitionLanguage("en-US");
AudioStreamFormat audioStreamFormat = AudioStreamFormat.getWaveFormatPCM(8_000, (short) 16, (short) 1);
PushAudioInputStream pushStream = AudioInputStream.createPushStream(audioStreamFormat);
AudioConfig audioConfig = AudioConfig.fromStreamInput(pushStream);
SpeechRecognizer speechRecognizer = new SpeechRecognizer(speechConfig, audioConfig);
PhraseListGrammar phraseListGrammar = PhraseListGrammar.fromRecognizer(speechRecognizer);
phraseListGrammar.addPhrase("Good morning");
phraseListGrammar.addPhrase("Good evening");
phraseListGrammar.addPhrase("Good afternoon");
phraseListGrammar.addPhrase("Good night");
phraseListGrammar.addPhrase("How are you");
phraseListGrammar.addPhrase("How have you been");
phraseListGrammar.addPhrase("How do you do");
phraseListGrammar.addPhrase("How is it going");
phraseListGrammar.addPhrase("It is nice to meet you");
phraseListGrammar.addPhrase("Pleased to meet you");
// start recognition
speechRecognizer.startContinuousRecognitionAsync().get();
// stop recognition
speechRecognizer.stopContinuousRecognitionAsync().get();
// close resources
phraseListGrammar.close();
speechRecognizer.close();
audioConfig.close();
pushStream.close();
audioStreamFormat.close();
speechConfig.close();
}
}
Version of the Cognitive Services Speech SDK 1.28.0
Platform, Operating System, and Programming Language
- OS: Amazon Linux 2
- Hardware - x86-64
- Programming language: Java 11
Additional context Environment variables used: LD_LIBRARY_PATH=<path_to_speech_sdk_native> SpeechSDK_UseCentos7Binaries=true MALLOC_ARENA_MAX=2
JVM options: -Xss256k -Xms15M -Xmx15M -XX:MaxDirectMemorySize=15M
Issue Analytics
- State:
- Created 3 months ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
The fix will be released in the next release end of June.
Awesome thanks. I don’t have a clear reproduction case but I am seeing similar sdk logging for ISpxNamedProperties and ISpxRecognitionResult where the tot number seems to increase and not have the corresponding StopTracking. Could those be looked at for the JNI layer too? Not sure if those have a similar issue.