Igor's Blog

My photo frame has had some new pictures added to it recently after which it started to crash. Turns out it was running out of memory. I guess 256Mb of RAM could not accommodate for a 128Mb JVM as well as the OS. I decided to add some virtual memory swap space to it only to find that dphys-swapfile was not installed by default in Minibian. This article describes the steps I followed to get virtual memory working.

First, this is the kind of error that I was seeing...
 dmesg output
[ 2923.832511] Out of memory: Kill process 2291 (java) score 611 or sacrifice child
[ 2923.839974] Killed process 2291 (java) total-vm:266796kB, anon-rss:131832kB, file-rss:4764kB


This was verified by running 'free'...
 free -h
total used free shared buffers cached
Mem: 212M 153M 58M 0B 10M 81M
-/+ buffers/cache: 62M 150M
Swap: 0B 0B 0B


No swap space! No big deal, just install dphys-swapfile as the root user.


 Command ran as root
apt-get install dphys-swapfile


During installation a 512Mb swap file is configured for you, but if you want to change that it can be done by editing the /etc/dphys-swapfile configuration file. The default is like this...
 /etc/dphys-swapfile
CONF_SWAPSIZE=512


Now just run the setup and turn on the swap space...
 Commands ran as root
dphys-swapfile setup
dphys-swapfile swapon


Running 'free' again confirms that the swap space has been added...
 free -h
total used free shared buffers cached
Mem: 212M 188M 24M 0B 12M 112M
-/+ buffers/cache: 63M 149M
Swap: 511M 0B 511M


These settings stay after a restart, so there is nothing else to do once you've set it up. After these changes I have not had a single crash.

I'd not recommend enabling swap on a Raspberry Pi unless you really need it and don't care about performance. In my case, it doesn't matter if it runs slower since it's just a photo frame, but the same won't apply in all use cases.

-i

, ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume

Subscribe


RSS Feed

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
StrFunc() Online
300 George St Blogumentary
Guru JSON-RPC Tester
Extrudifier Object Designer

Recent Blog Posts

Where to find the last item (Robbie's lost lyrics) in GravityFalls Lake level

Detecting print requests to print contents of a DIV with JavaScript

Using Google DFP with AdSense on responsive pages

How to change the email subject line in Gmail

Force PHP GD library to load JPEG images that have invalid data

How to uninstall Samsung Smart Switch from your Mac

Facebook adds weather forecasts but forgets to adjust them to your time zone

No sound or microphone when answering calls on an iPhone

Replacing the standard Odroid XU4 fan and heatsink

PHP PDO doesn't work binding multiple IN statement values

Recent Galleries

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth

Friends

RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
     
...or subscribe for updates!

Don't show this again