New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory Growth with PhraseListGrammar #1978
Comments
I tried enabling the sdk logging with the property PropertyId.Speech_LogFilename. It didn't write to the file with the reproduction case here but worked when using a spring controller to run essentially the same code. In the log file, it looks like the phrases have TrackHandlers that I don't see a corresponding StopTracking call for and the total number keeps incrementing. After 1 call to start, add 10 phrases, and stop:
After 101 calls:
The other TrackHandles appear to have a StopTracking called. The java sdk client only has addPhrase, clear, and close for PhraseListGrammar class. I tried clearing the PhraseListGrammar before closing it and still see this increase in memory and increase in total ISpxPhrase. |
That is strange. Are you only seeing this on CentOS7? I am not a java expert, but your cleanup code above looks correct to me. phraseListGrammar.close(); |
I'm able to reproduce this on a Mac (Big Sur) using the same reproduction code. I don't readily have a windows, ubuntu, or centOS8 machine to test on. Removing all the phraseListGrammar.addPhrase and the memory stabilizes with this example. The java 1.28.0 client-sdk has dispose as protected so I cannot call it. It looks like that is what close does though.
I think this memory is allocated off heap as part of the client-sdk native functions and garbage collection will not reclaim that memory. I did try nulling the object with the reproduction example but I see the same memory growth. |
One of my teammates spotted what looks like a leak in the JNI layer. Seems the same error is also in our C# binding (opened bug #5319969). |
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. |
@BrianMouncer |
Internal workitem ref: 5319958 |
The fix will be released in the next release end of June. |
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
Version of the Cognitive Services Speech SDK
1.28.0
Platform, Operating System, and Programming Language
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
The text was updated successfully, but these errors were encountered: