Two memory questions!


7 posts
by leewillis77 » Mon Apr 16, 2012 10:30 pm
Hi,

I got my Pi today (At last - great job to everyone at the foundation!) and I'm up and running, and just doing some preliminary bits and bobs. Two questions, both memory related.

Firstly, my system looks like it's running without any swap - see the screenshot here:

http://twitpic.com/9aohmm

Am I reading that right, and if so, any idea of the likely cause? I did resize the partitions on my sd card so maybe I stuffed that up? or maybe it's just not enabled by default?

Second question is that I'm planning on running headless (No display), what steps can I go through to ensure that the minimum possible memory is assigned to the graphics card / graphic related services?

Thanks for any suggestions!
Posts: 5
Joined: Mon Apr 16, 2012 9:23 pm
by mahjongg » Mon Apr 16, 2012 10:53 pm
As far as I know its intentional that swap is disabled, as the compilers of this distro were probably worried it would wear out the SD-card prematurely.

As for the minimum memory size for GPU, that is 32MB (I know its still quite a lot).

You can choose that by renaming the right "xxx_start.elf" file to simply "start.elf" (or was it "boot", not "start") anyway there should be three different versions of the GPU firmware, the default one is 64MB and there are also 32MB and 128MB ones.
User avatar
Forum Moderator
Forum Moderator
Posts: 5269
Joined: Sun Mar 11, 2012 12:19 am
by dom » Mon Apr 16, 2012 10:58 pm
leewillis77 said:

Second question is that I'm planning on running headless (No display), what steps can I go through to ensure that the minimum possible memory is assigned to the graphics card / graphic related services?

sudo cp /boot/arm224_start.elf /boot/start.elf

sudo reboot
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4011
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by leewillis77 » Tue Apr 17, 2012 4:20 pm
Brilliant - thanks for that - will give it a go!
Posts: 5
Joined: Mon Apr 16, 2012 9:23 pm
by plugwash » Tue Apr 17, 2012 4:31 pm
leewillis77 said:


Am I reading that right, and if so, any idea of the likely cause?


The image is not configured to use swap because swapping on SD cards is a BAD idea. SD cards suck at random write performance and suck at longevity under heavy write loads.

If you must have swap your best bet is probablly to put it on a USB HDD but honestly if you can't live within the ram available then the Pi is probablly not the right choice for your application.

zRam may also be an option though I dunno if the kernel the Pi guys supply is configured to support it.
Forum Moderator
Forum Moderator
Posts: 2233
Joined: Wed Dec 28, 2011 11:45 pm
by jojopi » Tue Apr 17, 2012 6:50 pm
plugwash said:

The image is not configured to use swap because swapping on SD cards is a BAD idea. SD cards suck at random write performance and suck at longevity under heavy write loads.

No arguments with that.

Except that being configured to use swap is not the same as swapping.  Just having swap enabled is not going to wear out your SD card unless you also start enough processes to contend your physical RAM.

But using even one page too much memory when you have no swap at all is certain to cause random processes to be killed, imperilling all your unsaved data.  I am not sure how guaranteed misbehaviour can ever be better than potential misbehaviour, in the same situation.  If you want data loss on a particular occasion you can always choose magic SysRq.

On topic: to enable swap, just remove the comment sign "#" from the swap line in /etc/fstab.  Then "swapon -a" or reboot.
User avatar
Posts: 2035
Joined: Tue Oct 11, 2011 8:38 pm
by plugwash » Tue Apr 17, 2012 10:44 pm
jojopi said:


Except that being configured to use swap is not the same as swapping.  Just having swap enabled is not going to wear out your SD card unless you also start enough processes to contend your physical RAM.


Afaict in certain cases linux will swap stuff out to make room for more disk cache. Which makes sense on a drive where read and write speeds are comparable but sucks on a SD card.


But using even one page too much memory when you have no swap at all is certain to cause random processes to be killed, imperilling all your unsaved data.


Using too much memory with overcommit enabled will cause processes to be killed. Swap will raise the threshold but it will not eliminate it and in exchange you are likely to have a period of time where the system is unusablly slow and wearing on your SD card pointelessly between when a runaway process runs out of ram and when it finally runs out of swap and gets killed by the OOM killer. Then another period where your system is slow as molasses while it gets swapped back in.
Forum Moderator
Forum Moderator
Posts: 2233
Joined: Wed Dec 28, 2011 11:45 pm