Number of Active Threads

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
Jipii
Posts: 72
Joined: 18 Aug 2008, 08:53
Location: Frankfurt, Germany

Number of Active Threads

Post by Jipii »

Hi,

the number of active threads (seen at remote administration) starts with 30 and ends up with over 300 before my virtual machine hangs up.

Is this good or not good? :wink:

How can I avoid this? Delete unused java objects, reseting the one scheduler I'm using...?
Thanks!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

I suppose you use AS on the server side, right?
If so you are probably starting threads when you run setIntervals.
Make sure that you call the clearInterval() method when you don't need the setInterval anymore otherwise you will be leaking threads.

Make also sure you are not starting too many Schedulers (like one per room) as this would not be optimal. One Scheduler object can handle the work of all Rooms.
Lapo
--
gotoAndPlay()
...addicted to flash games
Jipii
Posts: 72
Joined: 18 Aug 2008, 08:53
Location: Frankfurt, Germany

Post by Jipii »

I use 5% AS for one room and 95% java extensions and we made tests just in rooms with java ext.
In Java I use 1 ScheduledThreadPoolExecutor and I reset all scheduler after some seconds and purge them.
Thanks!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

In Java I use 1 ScheduledThreadPoolExecutor and I reset all scheduler after some seconds and purge them.
I don't understand exactly. Do you recreate the ThreadPool often?
If the thread count increases you are probably creating multiple thread pools?
I would need more details to understand.
Lapo
--
gotoAndPlay()
...addicted to flash games
Jipii
Posts: 72
Joined: 18 Aug 2008, 08:53
Location: Frankfurt, Germany

Post by Jipii »

Do you recreate the ThreadPool often?
Yes.
Now I found the solution: Not set the threadpool variable to null, but run the method shutdown().
It work's. After 2 minutes one threadpool in a object will now be deleted by shutdown() and another one will be started (= currently is always just one threadpool active). Is this okay or should I avoid start a threadpool so often?
Because: My threadpool is in an object gameround, which exists always one time. After some playing, this object will be delete and a new object gameround is created.
Thanks!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Thread pools should rarely be created and destroyed. Ideally you should create the thread pool once and never destroy it (unless you reload your extension or restart the server)
Lapo
--
gotoAndPlay()
...addicted to flash games
Jipii
Posts: 72
Joined: 18 Aug 2008, 08:53
Location: Frankfurt, Germany

Post by Jipii »

Okay, thanks.
My pool is now in a permanent object without recreation. :)
Thanks!
Post Reply