Heigvd / Wegas

A Web Game Authoring System coded in Java and Javascript for rapid development of serious games without programming skills.
https://wegas.albasim.ch
MIT License
28 stars 15 forks source link

Memory leak on prod/dev server #1951

Open xgo-work opened 3 months ago

xgo-work commented 3 months ago

Production instances regularly have heap filling up issues. The problem is now mitigated by restarting all the instances every night.

This issue is aimed at gathering informations centralize and track those leaks.

Potential culprits are objects that require to be manually disposed, or objects which always keep references on them (can be circual references)

Possibilites that should be investigated

FencedLock used for cache sync (from Hazelcast)

https://docs.hazelcast.org/docs/latest/javadoc/com/hazelcast/cp/lock/FencedLock.html Needs to be destroyed after use (but not so simple). There seem to be a limited amount though but worth checking out.

there is already admin calls that fetch some of them. https://wegas-dev.albasim.ch/#/admin/locks

Files retrieval using oak JCR

We need to check wether this is done correctly. Example from https://dzone.com/articles/creating-a-content-repository-using-jackrabbit-oak

Node fileNodeParent = session.getNode("pathToParentNode"); // /node1/node2/
Node fileContent = fileNodeParent.getNode("theFile").getNode("jcr:content");
Binary bin = fileContent.getProperty("jcr:data").getBinary();
InputStream stream = bin.getStream();
byte[] bytes = IOUtils.toByteArray(stream);
bin.dispose();
stream.close();

oak JCR Sessions

Each transaction with oak jcr repository happens in a session that has to be opened and closed.

See https://jackrabbit.apache.org/oak/docs/construct.html

In WEGAS session creation and release happens here

https://github.com/Heigvd/Wegas/blob/master/wegas-core/src/main/java/com/wegas/core/jcr/SessionManager.java

But not sure that sessions are closed in all use scenarios