MeshCentral icon indicating copy to clipboard operation
MeshCentral copied to clipboard

Memory Leak

Open TobinSol-Matt opened this issue 5 months ago • 11 comments

Describe the bug Mesh Agent uses more and more RAM over time until the device it's installed on runs out after approximately 12 hours and we have to reboot it. This started some time between October 25th and October 27th and no changes were made by us as far as we know.

To Reproduce Only reproducible on one of our 40 deployed agents.

Expected behavior Expect it to use a steady and low amount of RAM.

Screenshots

Image

Image

In the second screenshot you'll see it using 48.9% of available memory after 5.25 hours. It continues to increase until the 12hr mark as mentioned above.

Server Software (please complete the following information):

  • OS: Ubuntu 22.04.5 LTS
  • Virtualization: Proxmox
  • Network: LAN/WAN
  • Version: 1.1.53
  • Node: Unsure

Client Device (please complete the following information):

  • Device: A different virtual machine than the one above
  • OS: Ubuntu 22.04.5 LTS
  • Network: Local to Meshcentral
  • Browser: Google Chrome
  • MeshCentralRouter Version: Unsure

Your config.json file Don't know where to find this, will keep looking and add it later.

TobinSol-Matt avatar Nov 03 '25 14:11 TobinSol-Matt

Plz can u upload the images to the issue instead of imgur links? (Im UK and imgur has been blocked/banned in the UK now, and i dont pay for a vpn access anywhere)

si458 avatar Nov 03 '25 20:11 si458

Done, thank you.

TobinSol-Matt avatar Nov 03 '25 20:11 TobinSol-Matt

Strange one but are u having Internet issues at all?

The memory leak we know about (but not sure how to fix yet) happens when the device in question struggles to connect to meshcentral and it retries the connection over and over again

This isn't a meshcentral problem but a meshagent issue (you can check the meshagent repo about this)

Edit: a simple memory fix is to just restart the meshagent every so often service restart (from the console tab of the device in the Web ui)

si458 avatar Nov 03 '25 20:11 si458

No internet issues that I'm aware of. Other agents on the same network don't have this problem. Should I post this on the meshagent github?

TobinSol-Matt avatar Nov 03 '25 20:11 TobinSol-Matt

You can do if you wanted but the is already open issues about this problem in the repo https://github.com/Ylianst/MeshAgent/issues/110 https://github.com/Ylianst/MeshAgent/issues/281 https://github.com/Ylianst/MeshAgent/issues/151

The issue as explained is because the meshagent loses connection to meshcentral and reties over and over again until it reconnects successfully and the is a leak somewhere

You can actually test/see this for yourself, install the agent on a Linux machine, then block its Internet access, then watch the memory and after about 5-10mins it starts climbing...

Sadly we need a c++ developer to look into the code to where its leaking from

The is also a work around too a gent came up with that if its more than 128mb in ram then just restart the service and this uses Linux itself, will reply back when I find link to the fix! https://github.com/Ylianst/MeshAgent/issues/281#issuecomment-3109202154

si458 avatar Nov 03 '25 20:11 si458

Also from the screenshot the is a huge gap with no data, also the memory leak doesn't climb so quickly its gradually

So i would say this is the problem, the was an Internet outage with the machine in question and this caused the memory leak in the meshagent sadly

si458 avatar Nov 03 '25 20:11 si458

The VM was just turned off during that gap in the screenshot. But I'll look into possible connectivity problems. Thanks.

TobinSol-Matt avatar Nov 03 '25 20:11 TobinSol-Matt

Sadly we need a c++ developer to look into the code to where its leaking from

Does this mean you don't have a C++ developer?

DBMTC avatar Nov 04 '25 07:11 DBMTC

@DBMTC yes sadly we dont have a C++ developer, MeshCentral is a community driven project/appliation and rely on the community to help it survive and live on! im more of the backend end dev which can fix the meshcentral sever side things we have dan the docker man, and we have a few others who help with UI changes etc (html/css/js) but we sadly dont have anyone who knows c++ for linux/mac/windows etc who can help us fix things thats wrong with the meshagent 👎

si458 avatar Nov 04 '25 08:11 si458

I'm more of C than C++, but I'm getting a bit used to it and I would like to have a look into it.

A few questions for @TobinSol-Matt : · Are you using any MeshCentral plugins? [Updated to ping the correct person. Sorry DBMTC!]

panreyes avatar Nov 05 '25 10:11 panreyes

I am not using meshcentral at all, I am going to evaluate it.

Can you use valdgrind to start the incriminated service that is memory leaking and reproduce the leaking? Valgrind should be able to give you a clue on what to look for... Ideally this is something that can be solved with a bit of unique_ptr or shared_ptr magic.

I can perhaps help you in getting this fixed...

DBMTC avatar Nov 07 '25 07:11 DBMTC

I am not using meshcentral at all, I am going to evaluate it.

Can you use valdgrind to start the incriminated service that is memory leaking and reproduce the leaking? Valgrind should be able to give you a clue on what to look for... Ideally this is something that can be solved with a bit of unique_ptr or shared_ptr magic.

I can perhaps help you in getting this fixed...

If you are willing to help, you are welcome!

DaanSelen avatar Dec 16 '25 22:12 DaanSelen