Getting "cannot allocate memory" error, although running in real time

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

raboof wrote:
Linuxmusician01 wrote:On my current system (Mint 17.1 'Rebecca') I cannot install jack_control and it is not installed. But on my "toy" (antique little laptop) with Debian 10 'Buster' it is installed. How did y'all install jack_control?
I think Mint is Debian-based as well right? Then a useful tool is 'apt-file': 'apt-file jack_control' shows this tool is in the jackd2 package.
Thanks for the tip! I don't know why I couldn't find it in Mint (indeed, Debian based) before? It appears to be already installed on my system today (indeed, via the jackd2 package).

P.S. How can I check on a running instance of Jack how many ports it is using?
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by merlyn »

Nachei wrote:any idea of what they could mean?
They all happen within a second, so I think this is simply part of the process of shutting down JACK. Nothing to worry about. :)
Linuxmusician01 wrote:How can I check on a running instance of Jack how many ports it is using?

Go by what JACK was started with. As far as I know there isn't a way to get the JACK server to output this value. Also if you're using jackd I don't think jack_control will do anything. My understanding is that jack_control writes to ~/.config/jack/conf.xml, which is only used by jackdbus.
Nachei
Established Member
Posts: 235
Joined: Fri Feb 17, 2012 3:32 am
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Getting "cannot allocate memory" error, although running in real time

Post by Nachei »

merlyn wrote:
Nachei wrote:any idea of what they could mean?
They all happen within a second, so I think this is simply part of the process of shutting down JACK. Nothing to worry about. :)
Yup, I've been using my system some more these days and it's rock solid (I'm able to record midi drums LIVE for the first time ever!), so I don't even pay attention to those messages any more... Thank you again merlyn. :)
User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

merlyn wrote:
Nachei wrote:any idea of what they could mean?
They all happen within a second, so I think this is simply part of the process of shutting down JACK. Nothing to worry about. :)
Linuxmusician01 wrote:How can I check on a running instance of Jack how many ports it is using?

Go by what JACK was started with. As far as I know there isn't a way to get the JACK server to output this value. Also if you're using jackd I don't think jack_control will do anything. My understanding is that jack_control writes to ~/.config/jack/conf.xml, which is only used by jackdbus.
Thanks for the info. Always difficult to deal with: jack, dbus and jackd.
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by merlyn »

@Linuxmusician01 : You could work out how many ports are being used from the amount of memory JACK has allocated.

Code: Select all

$ ls -l /dev/shm
total 80444
-rw-r--r-- 1 merlyn merlyn 82280346 Aug 27 11:09 jack-1000-0
-rw-r--r-- 1 merlyn merlyn     1187 Aug 27 11:09 jack-1000-1
srwxr-xr-x 1 merlyn merlyn        0 Aug 27 11:09 jack_default_1000_0
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_catia
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_dbusapi
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_freewheel
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_system
-rw-rw-rw- 1 merlyn merlyn    70744 Aug 27 10:54 jack-shm-registry
82280346 bytes is 2048 ports.
User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

merlyn wrote:@Linuxmusician01 : You could work out how many ports are being used from the amount of memory JACK has allocated.

Code: Select all

$ ls -l /dev/shm
total 80444
-rw-r--r-- 1 merlyn merlyn 82280346 Aug 27 11:09 jack-1000-0
-rw-r--r-- 1 merlyn merlyn     1187 Aug 27 11:09 jack-1000-1
srwxr-xr-x 1 merlyn merlyn        0 Aug 27 11:09 jack_default_1000_0
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_catia
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_dbusapi
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_freewheel
-rwxr-xr-x 1 merlyn merlyn       12 Aug 27 11:09 jack_sem.1000_default_system
-rw-rw-rw- 1 merlyn merlyn    70744 Aug 27 10:54 jack-shm-registry
82280346 bytes is 2048 ports.
Thanks! How do you come up with that number? Divide it by 40176?
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by merlyn »

17374746 bytes is 128 ports, so it's not mem = k * ports, it's something like mem = k * ports + c.

OK, I'll work it out :)

k * 128 + c = 17374746 --- (1)

k * 2048 + c = 82280346 --- (2)

(2) - (1)

1920 * k = 64905600

k = 33805

sub in (1)

c = 17374746 - 4327040 = 13047706

So the equation is : mem = 33805 * ports + 13047706

so

ports = (mem - 13047706)/33805
User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

merlyn wrote:17374746 bytes is 128 ports, so it's not mem = k * ports, it's something like mem = k * ports + c.

OK, I'll work it out :)

k * 128 + c = 17374746 --- (1)

k * 2048 + c = 82280346 --- (2)

(2) - (1)

1920 * k = 64905600

k = 33805

sub in (1)

c = 17374746 - 4327040 = 13047706

So the equation is : mem = 33805 * ports + 13047706

so

ports = (mem - 13047706)/33805
Again: thanks! I'm a Master in physical chemistry so I appreciate equations very much. Irritating question once again (please forgive me): how did you come up w/ the number of 17374746?
User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

By the way, on my Raspberry Pi running on Raspbian I got rid of the error "cannot allocate memory" by following the instructions this link. Add to /etc/security/limits.conf:

Code: Select all

   your_user_name        soft      rtprio      90
   your_user_name        soft      memlock      unlimited

   @audio        hard      rtprio      90
   @audio        hard      memlock      unlimited
 
   @video        hard      rtprio      90
   @video        hard      memlock      unlimited
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by merlyn »

Linuxmusician01 wrote:how did you come up w/ the number of 17374746?
It's from my verbose JACK log. See this post : https://www.linuxmusicians.com/viewtopi ... 34#p109364. I could also have got it from ls -l /dev/shm

I knew the number of ports from my Cadence settings.
Linuxmusician01 wrote:By the way, on my Raspberry Pi running on Raspbian I got rid of the error "cannot allocate memory" by following the instructions this link. Add to /etc/security/limits.conf:

Code: Select all

   your_user_name        soft      rtprio      90
   your_user_name        soft      memlock      unlimited

   @audio        hard      rtprio      90
   @audio        hard      memlock      unlimited
 
   @video        hard      rtprio      90
   @video        hard      memlock      unlimited
The problem that @Nachei was having was that these changes had been made to limits.conf and he was still getting 'cannot allocate memory'. It's a bug in systemd 240 where user defined limits are ignored. It's still possible to lock memory but the bug means that there is a limit of around 50MB. 1024 ports involves around 47MB of memory, so 1024 ports works.
User avatar
Linuxmusician01
Established Member
Posts: 1503
Joined: Mon Feb 23, 2015 2:38 pm
Location: Holland
Has thanked: 734 times
Been thanked: 130 times

Re: Getting "cannot allocate memory" error, although running in real time

Post by Linuxmusician01 »

@Merlyn: thank you for the explanation! :)
Post Reply