Hello!
I have some questions about websocket instances/threads.
I have implemented a websocket server with many subs in the websocket class, that call SQL connections to a MariaDB database, a second MySQL database and creating many Map collection objects.
The SQL connections are opening from pools declared to Main module and after usage they are closed.
The result is some days after the server starts running, I have a large memory usage. The Eclipse MAT analyser, shows that the largest amount of memory used, comes from:
1. java.util.concurrent.ConcurrentHashMap$Node (40 MB of memory - 35% of usage)
2. com.mysql.jdbc.JDBC4Connection (29 MB of memory - 25% of usage)
I think the problem is the concurrent calls and creations of such objects inside every websocket thread that Garbage Collector does not anticipate to destroy them in a proper time manner.
My main question is: If I move the subs creating maps and calling SQL connections to a Code module and websocket threads make calls to them, will the program continue to create such objects for every concurrent thread?
Another question is: If the solution is to move all these subs to a code module, which is the best method to call them from websocket instances?
Direct call like: WsUtils.TestSub(data as map)?
Using CallSub or CallSubDelayed?
How to ensure that these objects will be destroyed as soon as possible?
Thank you in advance!