Page 1 of 1

Thread keep increasing and Sudden Jump in heap memory

Posted: 21 Mar 2024, 02:43
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;

Re: Thread keep increasing and Sudden Jump in heap memory

Posted: 21 Mar 2024, 02:54
by hng

Re: Thread keep increasing and Sudden Jump in heap memory

Posted: 21 Mar 2024, 08:21
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

Re: Thread keep increasing and Sudden Jump in heap memory

Posted: 21 Mar 2024, 12:14
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.

Re: Thread keep increasing and Sudden Jump in heap memory

Posted: 21 Mar 2024, 13:32
by hng
Edit:

Code: Select all

sfs.removeAllEventListeners()

Re: Thread keep increasing and Sudden Jump in heap memory

Posted: 22 Mar 2024, 07:22
by hng
ok just found the culprit, got some bugs not shutdown the executor after finish the task :)