views:

59

answers:

2

I'm pretty sure I'm not going mad when I say that Thread objects do not seem to be garbage collected in my J2ME application when running on the WTK emulator (v 2.5.2_01).

I have a console message when my run method exits, and it is printed. At the same time I make a call back to the only object that has a reference to the thread and tell it to null its reference, which it duly does.

I then start a new thread later on in exactly the same way. Every time I start a new thread, the number of Thread objects on the WTK's memory monitor goes up by one. It never goes down. Start enough threads and eventually my app starts to slow down.

Is this a known bug in the WTK or am I actually going mad?

A: 

Is there any option under preferences to enabled "Excessive GC Mode" ?

adatapost
Nope. Perhaps it's not in this version. There is a 'Perform GC Now' button which doesn't collect the threads no matter how often or hard the button is pressed.
izb
A: 

Are you absolutely positive no other object contains a reference to this Thread, and that there is no way that this Thread is actually still doing anything?

matt b
Positive. The thread is a private member that is never returned out of the containing object. The reference is never duplicated anywhere. It is definitely nulled when the thread definitely exits.
izb