Hardware Reference
In-Depth Information
On Raspbian, it is also possible to configure an explicit memory split by using the
raspi-config
utility. Launch
raspi-config
as root, and select the Memory Split option.
For most of the hacks and projects in this topic,
gpu_mem=128
should be a good place
to start. It's the setting that has given us the best possible overall performance in most
of our tinkering. Feel free to experiment, though, as the only real damage you can do
is to the Raspberry Pi's performance, and you can always change it back.
Automatically Share Memory
While you might be able to guess how much memory you want to split between the
CPU (OS) and the GPU (graphics), there are a lot of situations where you probably will
not know for sure. In cases like this, you really want to be able to configure your Rasp-
berry Pi to split the memory on the fly, allocating it between the CPU and the GPU as
needed.
As of the post-November 2012 firmware and 3.6 Linux kernel updates, there is a better
way to manage the GPU/CPU memory split. Called the Contiguous Memory Allocator
(CMA), it enables a dynamically managed memory split between the GPU and the
ARM CPU by setting low- and high-water marks for the GPU.
The
config.txt
parameter for the GPU low-water mark is
cma_lwm
, and
cma_hwm
is the
parameter for the GPU high-water mark. In order to use these parameters, you also
must pass some options to the Linux kernel at boot time. You can do this by adding
these options to
cmdline.txt
(on the boot partition of the SD card):
coherent_pool=6M smsc95xx.turbo_mode=N
This change to
cmdline.txt
also has the side-effect of disabling the
turbo mode
for the built-in ethernet controller on the Raspberry Pi, but you might not mind too
much unless you have a network-intensive use case. Disabling
turbo mode
also
sometimes improves wireless network performance (and eliminates a lot of DE-
BUG noise in the system logs in some cases).
In this configuration, you will also need to set the following values in
config.txt
:
gpu_mem_256=112
gpu_mem_512=368
cma_lwm=16
cma_hwm=32
cma_offline_start=16
Once you have rebooted the Raspberry Pi with these settings in place, it will result in
466 MiB memory free (212 MiB on the 256 MiB Model B unit) for the Linux userspace
by default, with more allocated to the GPU as needed (within the watermarks).