Is it possible to add RAM to a Raspberry Pi?
No. There is no method by which RAM can be added to the Pi. See this discussion on the raspberrypi.org forums for more details, but basically the RAM and CPU are inextricably, inaccessibly connected. There is no physical method by which RAM could usefully be added, unless you want to start acid stripping the CPU chip, getting your microscope out and tracking down a micrometer scale soldering iron.
On a 256MB Pi it should theoretically be possible to replace the chip with a 512MB one but it would not be easy. You would have to carefully heat up the PoP stack and then somehow seperate processor from ram chip. Then cleanup the mess of old balls and solder down the new ram chip.
Theres also the question of whether the firmware would cope, 512MB models have different ID codes burned into the OTP on the SoC from 256MB models and i'm not sure if the boot code would work properly if things didn't match.
On 512MB BCM2835 based pis no upgrade is possible, the memory controller was designed to support 1GB but there was a bug that stopped it working properly at that size.
On The raspberry pi 2 Mdoel B and raspberry pi 3 model B 1GB is the limit, the design of the bus strucure and memory controller in the Soc simply doesn't support more.
If we see a 512MB BCM2837 based Pi (e.g. a Raspberry pi 3 model A) then I expect an upgrade to 1GB will be theoretically possible but again BGA rework would be needed (though you wouldn't have the fun of PoP) and I don't know if there would be firmware issues.
If the SoC could support more, the designers would probably have included more memory, as others pointed out. There is a much more important reason, though: cost control.
The price difference, for that kind of part, between 512M and 1G is under USD 1; both are around USD 5. Even an 8G IC in that category is around USD 14, so you might think, big deal, up the price a bit. It's not that simple.
The 3 retails for USD40; its BOM is probably under $15, so even an extra dollar would significantly impact the retail price, percentage-wise. And although some people might buy a more expensive pi for more money, merely making two versions available increases costs (design, testing, distributing, stocking, etc.), and your $40 1G model might have to sell for $45 instead. You and I might not care, but that does make a big difference to the educational market, at which the Pi is primarily aimed.
Also, when you work with a constrained budget, you have to make decisions over what to include. I, for one, am a lot happier about having wifi and bt on the 3 than I would be with extra memory. Your experience my vary, but so far I've never needed more memory, but everything I've used the pi for needs WiFi, so saving me $5 on a wifi dongle was a choice I like.
If you absolutely need more memory than that, there are other (more expensive) options around!
You can't add RAM to a raspberry pi but raspberry pi clusters are another thing
Since someone requested, I will summarize the link above. Although I myself is not familiar with the details, it seems that it is possible to "connect" raspberry Pi(s).
"Kiepert ran the High Performance Linpack (HPL), the standard supercomputer benchmark on his home-made computer and found that his RPiCluster with its 32 Broadcom BCM2708 ARM11 processors running are 1GHz and 14.6GB of usable RAM turned in a HPL peak performance of 10.13 GFLOPS"
If you only need more memory to work and you run a Linux Distribution it is possible enlarge the swap. For this follow the instructions here http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/. On my Rasp I found a swapfile her
/var/swap but this is only 100 MB. So I replaced it with a bigger one. Now my Rasp has 1 GB RAM and 4 GB swap.
The speed decreases if the swap is really needed. In normal operation this makes no effect to the performance. Take a look here en.wikipedia.org/wiki/Swappiness for further information. This solution should use if you need Memory for short time or memory peaks. Swapping to the SSD decreases the lifetime of the SSD. Remind, that swapping is not intended to enlarge the memory for normal operation use.
If you permanently look for more RAM and speed you should take a look here http://www.digitaltrends.com/computing/c2-offers-competitive-specs-to-raspberry-pi/.
Regarding to the discussion below here some example use cases, in which I would prefer swapping rather than changing hardware:
Build software on the target. Here there are two possibilities:
Using a single core to reduce the amount of needed memory. In my example this leads to a peak memory usage of 370 MB by an elapsed time of 9h 45min.
Using parallel build. In my example this leads to an peak memory usage of 1400 MB by an elapsed time of 4h 30min. But in nearly 98% of this time the used memory is below 1024 MB.
An application with an heavy initialisation process: Then it is known that the main part of the application needs less than existing RAM but the initialisation routine - which occurs only once a program life time - has some bigger memory peaks, swapping is an appropriate way to handle the need of memory.
To examine the hardware requirements you can use:
/usr/bin/time -v <program invocation>
this gives you these information
Command being timed: "program invocation" User time (seconds): 33164.02 System time (seconds): 1560.20 Percent of CPU this job got: 98% Elapsed (wall clock) time (h:mm:ss or m:ss): 9:45:12 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 379092 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 354 Minor (reclaiming a frame) page faults: 47740772 Voluntary context switches: 1049855 Involuntary context switches: 482091 Swaps: 0 File system inputs: 170240 File system outputs: 3477064 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0
Deteiled steps to add swap
- Create a swapfile of the desired size (here 32 GB) - sometimes a swapfile /swapfile already exits, so I name it swapfile2
# dd if=/dev/zero of=/swapfile2 bs=1G count=32
- Give it new rights
# chmod 600 /swapfile2
- make this file a swap file
# mkswap /swapfile2
- enable it
# swapon /swapfile2
- check the new swap
$ swapon -s Filename Type Size Used Priority /swapfile file 1054428 0 -1 /swapfile2 file 33554428 0 -2
- If it is required to be permanently added, add the new swapfile to the /etc/fstab
and add the line
# nano /etc/fstab
/swapfile2 none swap sw 0 0