6

I have installed cayenne on my phone to monitor my Raspberry pi more easily. I typed free into the terminal and it also confirms the high ram usage. I've tried sudo apt-get clean and this hasn't helped at all. So with knowing this, how do I free up RAM for better performance. My PI keeps crashing inconveniently.

Im running a RPI3 with raspbian Jessie on a 64Gb micro SD card. sudo apt-get update and sudo apt-get upgrade have already been run and successful. Screen shot of the Cayenne interface is attached. Cayenne Interface

  • 4
    Something seems odd there though, the RPi3 has 1gb of RAM, not 500mb... It also has a 1.2ghz ARMv8... – Ron Beyer Jul 20 '16 at 4:11
  • 5
    Note that there is a significant difference between measuring RAM usage with and without the page cache. Some tools are ambiguous (like the one in the screenshot); others (such as free) are commonly misinterpreted. It is totally normal for a running system to use almost all available RAM eventually via this caching, as it is beneficial to the performance of the system. You need to clarify for yourself and the question what proportion of this is "buffers" or "cache" vs. what is actually committed memory. – goldilocks Jul 20 '16 at 4:15
  • @Ron Beyer, You know... I didn't notice that. And you're right. Maybe it's a communication issue between the pi and Cayenne? – BadgerTrucking Jul 20 '16 at 4:15
  • 1
    Although the 700 Mhz is strange since even when using a scaling governed I do not think 700 Mhz is one of the Pi 3's stops but I'm not sure -- you can check in /sys/devices/system/cpu/cpufreq/policy0/; the cpuinfo_cur_freq node is the current actual frequency in (oddly) deca Hz, e.g. 700000 would match 700 Mhz. If it ain't that, that GUI meter is confused. @BadgerTrucking See my comment on thlingan's answer, and I think the version of free on Raspbian is one with an explicit "+/- buffers/cache" line. – goldilocks Jul 20 '16 at 4:32
  • 1
    Please read this about ram: linuxatemyram.com – Huczu Jul 20 '16 at 8:58
7

@Jacobm001, I don't know if you'd call it high, but I currently have GPU set at 500. I noticed that at or above 600, the PI becomes VERY unstable. Frequent crashes and lots of freezing.

Oh, trust me that's incredibly high for an RPi. 500 in this case is 500 MB. The Pi only has 1 GB of available memory, which is 1024 MB... Essentially, you're dedicating half of your system's available RAM to the GPU.

If you're going to use a camera, it requires 128 MB of memory to be allocated to the GPU, but for anything else, the default 64 MB is plenty.

In a previous edit I flippantly joked about setting it to 0, but this isn't actually possible. The RPi needs a minimum of 16 MB allocated to the GPU, and if you set it to 0, the RPi will default back to 64 MB. Personally, I set my headless RPi to 16 MB.

| improve this answer | |
  • well, "headless" is a relative term. Usually to SSH to ALL my Pi's, I use JuiceSSH on my mobile. However, like tonight, I am remote desktop from my Laptop to mess around a little while watching TV. – BadgerTrucking Jul 20 '16 at 4:42
  • 2
    @BadgerTrucking: Most people tend to refer to systems without a GUI as "headless". I never use a desktop on my main RPi for example, so I don't give the GPU any memory. If you use a remote desktop on occasion, then yes, you'd want to leave some memory for it. – Jacobm001 Jul 20 '16 at 4:45
  • You can't effectively set it to 0, the minimum is 16 and the default is 64. You could try setting it to 0 to see whether that's ignored (in which case you will end up w/ 64) or ends up using the minimum. You can check w/ vcgencmd get_mem gpu. 16 is actually fine for a GUI if you aren't using openGL or watching video. The camera requires 128. There's also a description of using a dynamic split there, but note in practice that will probably make your minimum 32. – goldilocks Jul 20 '16 at 14:59
  • @goldilocks: yeah, I guess I really didn't think that bit of sarcasm through... I'll edit. – Jacobm001 Jul 20 '16 at 15:07
4

First, just like other answers pointed out, having that amount of RAM available for use is unusual.Consider lowering the amount of RAM dedicated to GPU to something like 128Mb,64Mb or even 0 if you don't need any graphics and use it as a headless server.

Second, unused RAM is wasted RAM.It is completely fine for Pi(or any Linux system for that matter) to report around 95% or RAM usage.All that RAM is used for caching so the system can run faster instead of just not using(effectively wasting) RAM. Check if something is actually using that RAM with tools like htop to be sure it is just Linux trying to speed everything up.If you need to kill some processes you can use tools top , pkill or pgrep(for finding PID) and kill(for actual killing).

| improve this answer | |
2

Install htop on your Pi and run it locally, it will tell you not only how much RAM is being used, but by whom. You can the kill memory-hungry processes you don't need.

| improve this answer | |
  • 1
    I think htop's mem bar differentiates between cache and truly committed memory via color, but the number at the end excludes the cache. Beware WRT "memory-hungry processes" that: 1) What counts is the RES figure, ignore VIRT; 2) htop may by default show process threads, which can make it look like there are many instances of one process using identical amounts of memory when really what this indicates is one process with multiple threads sharing the same block of memory. You can toggle between the two views with capital H, it should be obvious which is which. – goldilocks Jul 20 '16 at 4:23
  • @goldilocks, I noticed that. There were a bunch of processes that had 5 or so duplicates. – BadgerTrucking Jul 20 '16 at 4:44
  • @BadgerTrucking that isn't unusual at all. Generally speaking, every thread of a process will look like a duplicate process if you unaccustomed to those kind of readouts. – Jacobm001 Jul 20 '16 at 4:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.