Reply
Deleted Account
Posts: 0

[NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

In recent controller versions (5.6.20+), memory allocation behavior has been changed. The controller now allocates a full gigabyte of memory by default. On memory-constrained systems, this allocation may fail, causing the controller to fail to start. If you experience this, you can configure the initial memory allocation using the ‘unifi.xms’ setting in system.properties:

 

unifi.xms=256

 

The ‘unifi.xms’ setting controls how much memory the controller will request on startup. The controller will dynamically allocate more memory as needed, up until a limit set by ‘unifi.xmx,’ which defaults to ‘1024.’ Both of these settings are measured in megabytes.

 

A future release of the controller will improve the default allocation logic to make it more suitable for memory-constrained systems. However, adjusting these settings can be generally useful for a low-memory environment.

 

Please do not reduce these settings unless you experience memory related problems however, as they may result in decreased performance or increased memory contention.

 

Note that this does not affect the Cloud Key, and that the 'unifi.xms' setting is actually ignored on the Cloud Key.

Member
Posts: 162
Registered: ‎02-22-2014
Kudos: 44
Solutions: 7

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

Thanks @Deleted Account this is very valuable info as I got my Raspberry PI2 and PI3 working with below. If this info was present in release notes all of us should have save many hours. Kindly add this to all future UNIFI release notes

 

unifi.xms=512 (in /var/lib/unifi/system.properties)

 

 

I have disabled Swap file via below 

 

sudo systemctl disable dphys-swapfile

 

And post reboot checked the status via 

 

sudo systemctl status dphys-swapfile 

 

root@UnifiController:~# sudo systemctl status dphys-swapfile
● dphys-swapfile.service - LSB: Autogenerate and use a swap file
   Loaded: loaded (/etc/init.d/dphys-swapfile)
   Active: inactive (dead)
root@UnifiController:~#

 

New Member
Posts: 38
Registered: ‎05-09-2016
Kudos: 6
Solutions: 4

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

Thanks @Deleted Account!  After a failed upgrade attempt and a rollback to 5.5.24 due to the memory issue impacting devices such as the raspberry pi 3, it is great to see Ubiquiti post a formal Notice.

 

I can verify that setting unifi.xms=512 in /var/lib/unifi/system.properties, paired with JDK 8u162 built from tar.gz downloaded from JDK 8 Updates Early-Access Builds results in a successful upgrade to UniFi Controller 5.6.22 and snappy performance.

 

System memory usage under idle and normal loads is up ~10%, with ~ 30% available MEM remaining (and this is with ~340MB allocated to GPU ...

New Member
Posts: 7
Registered: ‎05-10-2016
Kudos: 1

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

Thanks @Deleted Account - using Amazon EC2 t2.micro - kept crashing and I wasn't sure why... this helps!

New Member
Posts: 1
Registered: ‎07-30-2014
Kudos: 3

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

Same problem here on AWS (EC2 t2.micro). The controller keep crashing.

I set now 

unifi.xms=256

unifi.xmx=512

and now is up and runnig.

i'll keep you posted

 

 

Established Member
Posts: 1,968
Registered: ‎10-26-2013
Kudos: 440
Solutions: 87

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

Do you consider a first-gen Cloud Key to be a memory-constrained system?

Gregg

New Member
Posts: 10
Registered: ‎11-23-2015

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

Hello.

 

After update CK to 0.8.2, Unifi service can't start and i can't log in via ssh to CK...

 

Unifi controller auto-update to 5.6.22-10205

 

I restarted CK, problems still... i shut down CK, problems still...

 

I tried to restore autobackup of unifi controller (v5.5.24) but dosen't downgrade... still versiom 5.6.22-10205...

 

Any idea to resolve this?

 

Thanks

New Member
Posts: 6
Registered: ‎08-16-2017

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)


@mottac wrote:

Same problem here on AWS (EC2 t2.micro). The controller keep crashing.

I set now 

unifi.xms=256

unifi.xmx=512

and now is up and runnig for 2 hours.

i'll keep you posted

 

 


I am running the exact same instance settings with a ubuntu machine. Controller was crashing every 2-3 hours prior to making these changes. After making these changes to the config file, the controller has been running for 24 hours and does not seem to have any lag.

 

Hopefully I did not jinx myself but just wanted to chime in.

New Member
Posts: 13
Registered: ‎05-27-2015
Kudos: 1

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

I had exactly the same issue with unifi service failing to start properly on a t2.micro after upgrading. I added these settings in /var/lib/unifi/system.properties and it came right up.
New Member
Posts: 10
Registered: ‎11-23-2015

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

But i can't access CK via ssh... when i write de password and hit enter, ssh client close.

 

If i tried to access via WinSCP, i recieved and error and cant connect to...

 

My CK is 1st gen

Deleted Account
Posts: 0

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)


@greggmh123 wrote:

Do you consider a first-gen Cloud Key to be a memory-constrained system?

Gregg


No, the settings mentioned here do not apply to the CK. The CK always unsets Xms and sets Xms to 768.

Deleted Account
Posts: 0

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)


@itjdel wrote:

But i can't access CK via ssh... when i write de password and hit enter, ssh client close.

 

If i tried to access via WinSCP, i recieved and error and cant connect to...

 

My CK is 1st gen


If you can't access your CK over SSH, your problems are unrelated to this. Please create a new thread and we will help you there.

New Member
Posts: 10
Registered: ‎11-23-2015

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

Hello!

 

I restore to default values and unifi controller dosen't works, but now, i can ssh to CK and change Memory Usage to 512 and now, Unifi service works fine! restore to last backup and works fine!!!

 

Thanks

Emerging Member
Posts: 80
Registered: ‎12-31-2013
Kudos: 30
Solutions: 2

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

Thanks for the heads up. I was having issues immediately after the update on a Debian EC2 instance on AWS.

 

I was also having a second issue since I ran unifi on port 443, was able to get that solved with the following command to allow the java process to bind low ports again:

 

setcap CAP_NET_BIND_SERVICE=+eip /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

 

Note, as pointed out by :

 


@jacobalberty wrote:

lingnau just a warning, by doing that command you are giving any java application you run on your system the ability to bind to any port they want.


 

Everything IT-related enthusiast. I can also tell you a thing or two about PRTG.

If I've helped you out, please mark "accept solution".
Highlighted
New Member
Posts: 37
Registered: ‎09-24-2015
Kudos: 246

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

lingnau just a warning, by doing that command you are giving any java application you run on your system the ability to bind to any port they want.

Emerging Member
Posts: 80
Registered: ‎12-31-2013
Kudos: 30
Solutions: 2

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)


@jacobalberty wrote:

lingnau just a warning, by doing that command you are giving any java application you run on your system the ability to bind to any port they want.


Yes indeed, I'm aware of that but I'm far from being a versed Linux user so that was the quick 'n' dirty solution that worked for me, but thanks for pointing out. I figured the risk is minimal since this is an EC2 instance (one requires the SSH key to login) and nothing else but unifi runs there.

 

Originally I wanted to give the service account that permission, but couldn't find a way to do it so I settled with that solution instead.

 

If you know of a better way, please let me know. Man Happy

Everything IT-related enthusiast. I can also tell you a thing or two about PRTG.

If I've helped you out, please mark "accept solution".
New Member
Posts: 37
Registered: ‎09-24-2015
Kudos: 246

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

You can either redirect port 443 to 8443 using iptables or something similar, modify the scripts to use capsh instead ( I haven't been able to get that one to work but in theory theres no reason it would work) or use https://mutelight.org/authbind . Those are all alternatives you could go with. Thought I was just making sure you knew the downsides to the setcap option. If you're aware of them and taking steps to mitigate (things like using ssh keys instead of passwords) it shouldnt be an issue for you.
Emerging Member
Posts: 50
Registered: ‎11-13-2013
Kudos: 4

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

I have 2nd generation Cloud Key and i have the same problem in 5.6.22, where i can change this?

 

I found this file in

/srv/unifi/data/system.properties

 

I have to add that line to the file?

 

Best Regards

New Member
Posts: 38
Registered: ‎05-09-2016
Kudos: 6
Solutions: 4

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

As a followup to my post on the adjustments to system.properties, I experienced instability withe the controller after 2+ days of uptime and full functionality, after which point the service would still be running but the controller web UI would not be available  System RAM usage steadily climbed to ~85% (raspberry pi3) ... Rather than continue to mod setttings and test/troubleshoot, I migrated my controller to my OMV NAS server and am now happily running the controller in a Docker container.

 

Perhaps if I had adjusted settings to the following, the issue may have been fully resolved ...

unifi.xms=256
unifi.xmx=512

I will revisit running the controller on the Pi after the unifi controller's memory usage implemenation is changed in future releases.

 

Respectfully,

 

New Member
Posts: 16
Registered: ‎02-23-2017
Kudos: 5

Re: [NOTICE] UniFi Controller Memory Usage (5.6.20+)

[ Edited ]

@ubnt-neersighted wrote:

@greggmh123 wrote:

Do you consider a first-gen Cloud Key to be a memory-constrained system?

Gregg


No, the settings mentioned here do not apply to the CK. The CK always unsets Xms and sets Xms to 768.



Are you certain about this? I have set the value's to unifi.xms=256, unifi.xmx=512 and now I'm able to login again with my credentials. CK 2nd gen.

Reply