Memory leak on Agent when connection to the CMR is not available

Description

The sprIT team has reported that they have a memory leak when running the agent for some amount of time without it being connected to the CMR. Although this is not a real usage scenario for us (why would Agent be there without the CMR), I still had a look on the heap dump they provided. And they were correct the Agent does make a memory leak.

Apparently every time we try to connect to the CMR we create a new instance of the kryonet Client for communication. If connect fails we do allow this object to be garbage collected, but it's obviously not collected.. Seams like the problem is that Client creates a thread when being constructed (Client thread) and this one has a hard reference to the Client itself. And this thread seams to stay alive although we call clearly Client.stop() method when connection fails.

In my opinion we have two options here:

  1. Keep current approach, but check how to terminate the update thread as well (maybe calling Client.close()) as well.

  2. Create only one client instance and just executed connect() method when connection is asked for

Environment

None

Assignee

Ivan Senic

Reporter

Ivan Senic

Labels

None

Integrator

Patrice Bouillet

Sprint

None

Fix versions

Affects versions

Priority

Highest
Configure