saikpr
Posts: 2
Joined: Tue Jul 02, 2019 6:25 am

RAM issues on the new Raspberry Pi 4 - 4GB

Tue Jul 02, 2019 6:33 am

I got a new 4GB variant of RPI-4 and recently ran into issues with in-ability to use the full 4GB of ram. I am unable to use more than 2900~3050 MBs of ram. and whenever a process tries to ask for more RAM it crashes.

I using the latest version of raspbian-lite (as on the site, 20th June version)

# How to reproduce?
install memtester : sudo apt install memtester

and then try to allocate 3500MB of ram, (provided that much is left) and you can see that the want is less than the got.

Code: Select all

sainyam in ~ at raspberrypi
➜ free -m
              total        used        free      shared  buff/cache   available
Mem:           3906          95        3723           8          87        3690
Swap:            99           0          99

sainyam in ~ at raspberrypi
➜ sudo memtester 3500M 10
memtester version 4.3.0 (32-bit)
Copyright (C) 2001-2012 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).

pagesize is 4096
pagesizemask is 0xfffff000
want 3500MB (3670016000 bytes)
got  2909MB (3050762240 bytes), trying mlock
BTW I am using this kernel

Code: Select all

Linux raspberrypi 4.19.50-v7l+ #895 SMP Thu Jun 20 16:03:42 BST 2019 armv7l GNU/Linux
I haven't been able to find a thread with this issue, and it might be that since the 4GB variant is rare, people might have not observed it. Can anyone try this on their RPI-4 4GB?

User avatar
schorsch76
Posts: 37
Joined: Sun Apr 28, 2013 8:01 am

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Tue Jul 02, 2019 7:20 am

Thats the problem with 32 bit processes. They can not use 4 GB as on Linux about 1GB virtual memory is locked for the kernel/Hardware/IO stuff.

https://elinux.org/images/b/b0/Introduc ... _Linux.pdf (see page 22)

lb
Posts: 261
Joined: Sat Jan 28, 2012 8:07 pm

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Tue Jul 02, 2019 7:34 am

That's correct, there is a per-process limit of 3 GiB. However, with multiple processes, you can still easily take advantage of all of the RAM. This is not an ARM-specific or Raspberry-Pi-specific problem.

I guess it will still take some time for Raspbian to move to 64 bit, but in practice, this should not be a serious issue.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23382
Joined: Sat Jul 30, 2011 7:41 pm

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Tue Jul 02, 2019 8:47 am

Note, we have LPAE extensions enabled in the Pi4 kernel to give access to the full 4GB (for multiple processes)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Gomoto
Posts: 125
Joined: Tue Feb 12, 2013 1:21 am

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Tue Jul 02, 2019 3:16 pm

My 2GB version spares me these kind of troubles :twisted:

saikpr
Posts: 2
Joined: Tue Jul 02, 2019 6:25 am

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Wed Jul 03, 2019 2:43 am

Thanks a lot for the explanation.

I wasn't able to find the documentation for 1GB reserved for system etc?

Only thing I found the logs, while trying to OOMed was this part

Code: Select all

Jul  3 03:20:08 raspberrypi kernel: [37994.182533] Free swap  = 91644kB
Jul  3 03:20:08 raspberrypi kernel: [37994.182537] Total swap = 102396kB
Jul  3 03:20:08 raspberrypi kernel: [37994.182540] 1012736 pages RAM
Jul  3 03:20:08 raspberrypi kernel: [37994.182544] 816128 pages HighMem/MovableOnly
Jul  3 03:20:08 raspberrypi kernel: [37994.182547] 12788 pages reserved
Jul  3 03:20:08 raspberrypi kernel: [37994.182551] 65536 pages cma reserved
which means (if I am not wrong) that (65536+12788) are reserved for kernel IO, which is 7.7% of the total memory, i.e. 302 MB. Which means we have 3604 (3906-302) for OS+user procs?

[*] Does 32 bit enable you to access full 4GB of storage, as 32bit is 4294967296 bytes of addressable memory[*]
[*] So when there is an OS build for arm64 and not armhf is released, this should be resolved?
[*] My assumption of 3604mb available to user + os holds based on my memtester tests., it might be that memtester prevents the pages from swapping and it is being OOMed.

Is it possible in future release to overcome this ~2900 limit?

PS: Logs, in case anyone is interested https://gist.githubusercontent.com/saik ... ssages.log

MisterEd
Posts: 90
Joined: Mon Apr 16, 2018 5:28 am
Location: Huntsville, AL USA

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Wed Jul 03, 2019 5:01 am

The same amount of RAM is reserved for system I/O and GPU whether you have 1, 2, or 4GB RAM. In other words you still lose the same amount RAM with 2GB as you do for 4GB. There are probably ways around this but there is a good chance the PI will at some point crash.

32-bit Windows has the same problem with 4GB RAM in that only about 3.2GB is available.

There is little advantage to 64-bit Raspian vs 32-bit Raspian unless you need more than 4GB RAM. With 64-bit Raspian with 4GB RAM you might even have less free memory than with 32-bit Raspian.

Memory options in config.txt
https://www.raspberrypi.org/documentati ... /memory.md

ejolson
Posts: 3423
Joined: Tue Mar 18, 2014 11:47 am

Re: RAM issues on the new Raspberry Pi 4 - 4GB

Wed Jul 03, 2019 1:39 pm

saikpr wrote:
Tue Jul 02, 2019 6:33 am
I haven't been able to find a thread with this issue, and it might be that since the 4GB variant is rare, people might have not observed it. Can anyone try this on their RPI-4 4GB?
A further clue explaining what you have discovered can be found in the memtester documentation.
memtester manpage wrote:memtester is also limited to the amount of memory available to a single process; for example, on 32-bit machines with more than 4GB of memory, memtester is still limited to less than 4GB.
From what I can tell memtester is single threaded. This means you could run four copies on the Pi 4B simultaneously one on each core. What happens if you try

Code: Select all

$ sudo bash
# memtester 832 10 & memtester 832 10 & memtester 832 10 & memtester 832 10
Do all four copies of memtester run and finish successfully? Note that the output from all four copies of memtester will be scrambled together in the same terminal window.

Return to “General discussion”