question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory Growth with PhraseListGrammar

See original GitHub issue

Describe 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:closed
  • Created 3 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jhakulincommented, Jun 21, 2023

The fix will be released in the next release end of June.

1reaction
evanyounggenesyscommented, Jun 14, 2023

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improving speech recognitio for Names of persons #605
What are the best practices to handle names of people in speech recognition as they are an open domain. What are the capbilities...
Read more >
Ms Azure cognitive quick start Speech to Text (adding ...
Try initializing the recognizer and passing it to the PhraseListGrammar. import azure.cognitiveservices.speech as speechsdk.
Read more >
What's new in Azure AI Speech?
Fixed a memory leak when using speech recognizer with PhraseListGrammar, as reported by a customer (GitHub issue).
Read more >
Wav2vec2.0 memory issue - Models
I am training locally. I have 24gb gpu. Error is RuntimeError: CUDA out of memory. Tried to allocate 562.00 MiB (GPU 1; 23.65...
Read more >
KnowBrainer Speech Recognition Forums - Memory Leak
I have a new PC that is a Duo Core porocessor 2.66 GHz, 2021MB memory RAM and 32-bit operating system using IE7 with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found