FreeTTSWordToSound is not deallocating Voices thus causing memory leakage

Description

Voice.java threads are remaining open because they are not deallocated. I am using the SpellerSoundFactory, SoundCaptchaFactory, SimpleCaptchaService, GenericCaptchaEngine and FreeTTSWordToSound. The FreeTTSWordToSound is definitely the problem. When viewing the source code for this class, there is no Voice.deallocate() method being called anywhere even though Voice.allocate() is called. There needs to be a method of deallocating the Voice objects (which are Runnable) thereby closing the threads and freeing up much needed memory during garbage collection.

I did a full stack dump of the JVM this morning. There are 360 stuck threads of type com.sun.speech.freetts.Voice$1. This is the cause of the problems.
---------------------------

"Thread-23" daemon prio=5 tid=0x007646c8 nid=0x54 in Object.wait() [0x409ff000..0x409ffc28]
at java.lang.Object.wait(Native Method)

  • waiting on <0x8eb77278> (a com.sun.speech.freetts.OutputQueue)
    at java.lang.Object.wait(Object.java:429)
    at com.sun.speech.freetts.OutputQueue.pend(OutputQueue.java:97)

  • locked <0x8eb77278> (a com.sun.speech.freetts.OutputQueue)
    at com.sun.speech.freetts.Voice$1.run(Voice.java:471)

"Thread-22" daemon prio=5 tid=0x011feb10 nid=0x53 in Object.wait() [0x40aff000..0x40affc28]
at java.lang.Object.wait(Native Method)

  • waiting on <0x8eb77300> (a com.sun.speech.freetts.OutputQueue)
    at java.lang.Object.wait(Object.java:429)
    at com.sun.speech.freetts.OutputQueue.pend(OutputQueue.java:97)

  • locked <0x8eb77300> (a com.sun.speech.freetts.OutputQueue)
    at com.sun.speech.freetts.Voice$1.run(Voice.java:471)

Environment

BEA Weblogic 8.1 SP5 SunOS/Windows XP/Linux RHEL 2.5GB or RAM allocated to the 1.4.2 JVM.

Activity

Show:
AntoineV
May 15, 2008, 11:35 PM

The voice.deallocate() has been added in the stringToSound.

Please configure your project to use the following Jar in order to test the change :
http://forge.octo.com/archiva/browse/com.octo.captcha/jcaptcha-extension-sound-freetts/1.0-20080515.232301-19

do not hesitate to reopen the issue if the bug still appears

Fixed

Assignee

AntoineV

Reporter

Kevin Boutin

Labels

None

Components

Fix versions

Affects versions

Priority

Critical
Configure