Thread keep increasing and Sudden Jump in heap memory

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

Post Reply
hng
Posts: 42
Joined: 01 Nov 2021, 18:17

Thread keep increasing and Sudden Jump in heap memory

Post by hng »

Dear Lapo,

I am building an NPC application based on https://smartfoxserver.com/blog/ways-of-working-with-npcs-in-a-multiplayer-game-p-2/

But i got an issue the thread keep increasing and sudden jump in heap memory.. Total have around 10-30 NPC active all the time, I had remove all new thread/listener in the each NPC, just the default SFS listener, the NPC apps using ZGC with no fix xms/xmx with total RAM in the machine in 16GB

I notice the thread keep increased when the NPC disconnect and connected again, below is my cleanup code, do i need anything else to clear the unused thread because the SFS server it self use very little live thread 300+ compare NPC apps 4000+

I still have no clue why there is sudden jump in heap memory

Could you share some insight please


Image

Image

Code: Select all

 sfs.removeAllEventListeners();
 sfs = null;
hng
Posts: 42
Joined: 01 Nov 2021, 18:17

Re: Thread keep increasing and Sudden Jump in heap memory

Post by hng »

User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Thread keep increasing and Sudden Jump in heap memory

Post by Lapo »

Hi,
the graph you have posted for the NPC manager shows a normal memory activity for the time interval measured. There is no evidence of an increasing usage of RAM in the diagram.
The situation seems the same for thread count, which is quite high, but it's a flat line from start to finish. So I am not sure where is the problem.

As regards the "memory spikes" those are just normal, they show a temporary allocation of memory that lasts for a very short amount of time and the is reclaimed. What you need to look at is the overall curve of memory usage over time, which does not look anomalous.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
hng
Posts: 42
Joined: 01 Nov 2021, 18:17

Re: Thread keep increasing and Sudden Jump in heap memory

Post by hng »

Thank you for your reply Lapo

is there any possible reason

Code: Select all

sfs.RemoveAllListener
failed?

In a very rare event I got error sfs not found when trying to remove the listener.
hng
Posts: 42
Joined: 01 Nov 2021, 18:17

Re: Thread keep increasing and Sudden Jump in heap memory

Post by hng »

Edit:

Code: Select all

sfs.removeAllEventListeners()
hng
Posts: 42
Joined: 01 Nov 2021, 18:17

Re: Thread keep increasing and Sudden Jump in heap memory

Post by hng »

ok just found the culprit, got some bugs not shutdown the executor after finish the task :)
Post Reply