ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.29k stars 636 forks source link

JVM Heap memory taking much more memory than expected #3548

Open ghost opened 3 years ago

ghost commented 3 years ago

Whenever I start any broadcasting the JVM heap memory taking 900 MB - 1 GB memory which is unusal for me. I have another server of ant media where JVM memory never cross 500 MB. Can you get clear JVM heap memory unusal case from UI itself otherwise I have to reboot either ant media or server.

image

mekya commented 3 years ago

Hi @adisahu1989 ,

Let me explain. In your instance, 3.8 GB is the maximum heap memory size that Ant Media Server can use. It's generally 1/4 of the total memory by default. In your case, Garbage Collector(GC) may not free the unused memory because it does not think that there is a lack of memory because %23 of the total space is allocated. It probably caches the memory for quick access. If there is a lack of memory in the system or in the process, GC becomes more aggressive to release the resources. So there seems no problem on your side.

If you would like to change the max memory usage, you can change by adding -Xmx option to antmedia.service file if you're running as a service. This file is located at /etc/systemd/system/antmedia.service and after you change it, don't forget to run sudo systemctl daemon-reload and restart the service (sudo service antmedia restart). If you're running start.sh directly, you can even add it to file directly.

I hope I could give an answer for your question.