Author Topic: Voice Attack or Windows Speech API memory leak?  (Read 6444 times)

Egil Sandfeld

  • Newbie
  • *
  • Posts: 25
Voice Attack or Windows Speech API memory leak?
« on: November 03, 2016, 10:05:01 AM »
Hi all :)

Really really really enjoy using Voice Attack and having a wonderful response from the people using my plugin, The Digital Race Engineer, for Voice Attack as well! So thanks a bunch, Gary =)



However, since the Windows 10 Anniversary Update (or somewhere in that period) I've experienced that Voice Attack takes up more and more memory when being used. It's visual in Task Manager (Ctrl+Alt+Del) where you can see the Memory load increasing and not dropping down again. This makes me think there's a memory leak somewhere.

I have several of my plugin users also saying that their Voice Attack crashes after being used about 30 minutes to 2 hours in, compared to how often they use VA actively in that period.


I've been debugging the hell out of my plugin as I thought this was the culprit at first. But it's not:


  • Plugin support enabled and disable does not make a difference
  • Using a populated profile or creating a new profile does not make a difference
  • Suspend/Resume listening is funny in that it doesn't jump up in clusters, but rather slowly increases Memory usage (on my end it's about 1mb per minute)
  • Commanding VA to print in console does NOT make memory jump
  • Commanding VA to say something with TTS DOES make memory jump
  • Tried both VA 1.5.12 and 1.5.12.31 and it does not make a difference
  • Tried both standard Windows TTS engines and Ivona Amy. Both creates a jump in memory ALTHOUGH by using Ivona, memory increases quicker




In the following video I try to demonstrate when exactly the memory rise happens.


https://www.youtube.com/watch?v=0d-QD0UjVg0



At first I try a test where VA responds to my Voice Input by typing out the current RAM usage only (When I say "Write test"). I do this a couple of times to show that the RAM change is sort of the same (not affecting RAM that much, and other apps and processes are also a part of these small changes)

Then I switch to test TTS (When I say "Say test"). It begins with printing out the RAM change before a 1.5 sec pause. Then follows the TTS string it self, and after this I measure the RAM used again. I do this test a couple of times to show that it bounces up the first time, hovers around the same RAM level in the next ones, but jumps further up after a few triggers of the "say test" command. Btw. it always have this behaviour, where it jumps up (about 10-15mb) on the first TTS command, and it always jump further up, after a few other TTS commands.



Note that ram/memory does not drop back down again. I have attached the Test profile, so you can try for yourself and see what it does on your system.



The question is if this is related to the Windows recent update, as I haven't noticed this behaviour before. And since my users keep reporting that their memory usage is high all of a sudden, there has happened something recently. I don't know if it's relating to VA, Windows or Speech Engine (remember to bigger jump in memory).



So I guess my questions are; Have you heard about others with the same issues, can you reproduce the issues;What do we do about it? :)


Using:
Voice Attack 1.5.12.31 BETA
Windows 10 Pro
i7-4770K 3.50Ghz
GTX 970 FTW+
16 GB Ram
Plenty of free space

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Voice Attack or Windows Speech API memory leak?
« Reply #1 on: November 03, 2016, 05:09:13 PM »
Hmmm... looks like it's not going back down.  I made a test for it... which was fun to do.  It sets five variables to the value returned from a random word web service then says them all in a single sentence with tts... over and over and over (attached).

I'll see what can be done.  Thanks for all the info, btw!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Voice Attack or Windows Speech API memory leak?
« Reply #2 on: November 03, 2016, 11:47:12 PM »
I moved some things around so see if they would stick, as well as be a little more aggressive on simultaneous synths and explicit garbage collection.  I'm thinking it helped, but I need to put it all back and compare.  I did read that there is a memory leak in the .net components and that using COM components does not exhibit the same leakage.  I'm going to defer the trial/switch over to COM components til later (probably v2).  I ran TTS continually for a whole hour and the leak was about 15 mb.  I would say that's doable for now, as who runs TTS continually for an hour?  ;)  I'll post the update tomorrow, hopefully.

Egil Sandfeld

  • Newbie
  • *
  • Posts: 25
Re: Voice Attack or Windows Speech API memory leak?
« Reply #3 on: November 04, 2016, 02:17:59 AM »
You are the man, Gary!! :D

On a racing session of up to 3 hours, it's not uncommon for my users to have a talking stream accumulated up to about 30 minutes.

Was it with your changes that leak was only 15 mb over an hour? Or before your changes?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Voice Attack or Windows Speech API memory leak?
« Reply #4 on: November 07, 2016, 06:40:00 PM »
The latest beta out there may help some.  I can't promise anything, but an attempt was made ;)

Egil Sandfeld

  • Newbie
  • *
  • Posts: 25
Re: Voice Attack or Windows Speech API memory leak?
« Reply #5 on: November 09, 2016, 12:41:49 PM »
Tested 1.5.12.33 through the last days and the issue persists unfortunately.

I did 3 tests using ANTS Memory Profiler 8 to profile memory usage of VA. Here are 3 screenshots of the tests.
In both tests I left VA idling where it would pick up small bits of talking from a video streaming through my speakers. I did not trigger any commands from this. All tests ran for about 14 minutes from after everything seemed to be loaded in VA (41 seconds after opening VA).

The first test includes my profile running my plugin in an idle state:

http://i.imgur.com/E3SJZ28.png


You can see the "spsreng" aka. Windows Speech Recognition Engine is really the only thing that considerally more memory usage than in the first snapshot (grey is the 00:41 snapshot).

The second test included starting VA with an empty profile with no commands or idling like the other with bits of talk being picked up by the mic but nothing triggered

http://i.imgur.com/ia1glmr.png


Third test is with Mic input turned off in VA, so no input is received.
http://i.imgur.com/gpeGYTI.png


I would say the results are sort of the same. So I'm thinking where this can come from. I've asked some of my users and the issues happen both on Windows 10 and 7. I previously though that maybe the Anniversary Update did something to Speech Engine with some Cortana changes or like, but this can't be the case if using Windows 7 shows the same results.

Another interesting find is that if I leave VA idle and don't say anything for about 5 minutes, and then say something, it immediately jumps memory usage up in Task Manager. It's like there's something going on every time speech engine tries to match a concrete voice input or something like that.


Looking in ANTS Memory Profiler Class List and Instance Retention Graph where it may display some clues, the top used area is "System.Drawing Icon" for the first two tests. Note though, for the last test with Mic-input turned off the top clue was "System.Bitmap Drawing". So this would indicate some UI hanging?

http://i.imgur.com/hPFXmoG.png

Looking into this is shows the following:

http://i.imgur.com/Y5jllh7.png

http://i.imgur.com/5nM4Mv3.png

http://i.imgur.com/pqiTlB4.png

I'm not sure what to make of this, but thought I would share it in the hopes that you would? I'm confused that on one end it points to "spsreng" as the culprit and other places icons or bitmaps.

Again, biiig thanks for looking into this :)

Gangrel

  • Caffeine Fulled Mod
  • Global Moderator
  • Full Member
  • *****
  • Posts: 216
  • BORK FNORK BORD
Re: Voice Attack or Windows Speech API memory leak?
« Reply #6 on: November 09, 2016, 03:01:41 PM »
What is it like without plugins running?

Egil Sandfeld

  • Newbie
  • *
  • Posts: 25
Re: Voice Attack or Windows Speech API memory leak?
« Reply #7 on: November 10, 2016, 01:15:06 AM »
Without any plugins or files in Apps folder and with "Plugin support" in VA unchecked, there's no memory leak it seems:

http://i.imgur.com/Kuxe60O.png


Also tried adding files and plugin back into the folder but still with Plugin support off:

http://i.imgur.com/Fcl9iWV.png
Much less in the "spsreng", in fact so little that it would probably not be an issue.

Oh boy, I'm pretty sure I tested the "Plugin support" unchecked before where I did see a memory increase for spsreng, but now it doesn't. Did you change anything in this area by any chance? :)


Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Re: Voice Attack or Windows Speech API memory leak?
« Reply #8 on: November 10, 2016, 08:50:59 AM »
The only thing changed was that the code checks for the plugin v4 interface and uses it if it is found.

I'll go back and do a diff between the current code versus the code prior to adding this to make sure, but I'm thinking that's all that's in there that is different.