Could Sd Cards, In Theory, Be Used As Ram In A Linux Environment?


Eet said:
Something to keep in mind is the fact that ARM instruction sets, by their nature, tend to use larger blocks of memory than their x86 counterparts.
In case you're referring to the size of the text segment in a binary, that might be technically true, but practically it's irrelevant. The difference in average codesize is negligible to be of any concern in a desktop environment - code volume there is by far not the leading RAM consumer. Now if pandora had 1MB of RAM you might have had some reason, but then again such a platform would've been largely coded in Thumb : )
 
Last edited by a moderator:
darkblu said:
Eet said:
Something to keep in mind is the fact that ARM instruction sets, by their nature, tend to use larger blocks of memory than their x86 counterparts.
In case you're referring to the size of the text segment in a binary, that might be technically true, but practically it's irrelevant. The difference in average codesize is negligible to be of any concern in a desktop environment - code volume there is by far not the leading RAM consumer. Now if pandora had 1MB of RAM you might have had some reason, but then again such a platform would've been largely coded in Thumb : )

I was thinking in more generalized terms that there are enough differences between an X86-based computer and the ARM-based pandora that we should be carefull about making too many assumptions about the pandora not needing a swap space just because most laptops and desktops don't.

Personally, I really hope that one isn't required, as I'd hate to sacrifice an SD slot and an SD card to enable it. Still, that'd be preferable to the swap space residing on the Pandora's built-in NAND :).
 
Last edited by a moderator:
Vitel said:
second exodous said:
Do you have a Linux server?
I have a Linux server, but the statement about is about my notebook.

second exodous said:
I never have very high use of my memory. I'm sure when I play recent games it goes up but I just use it for desktop use and I never get into swap. Right now I'm running firefox, rhythmbox and the normal stuff like compiz and such, that is basically all I use most of the time and I'm using around 14% of my 4 gigs of memory. I have 2 gigs of swap and have never seen it used, I just keep it around because when I ask Linux gurus they always say keep it around at half your memory just in case.
How do you calculate amount of free memory?

`top` shows 'real mem usage', which is four top lines from `/proc/meminfo`.
Code:
Mem:   3951928k total,  3895204k used,    56724k free,    24248k buffers
But `conky`, for example, treats memory used for buffers and caching as free. I.e:
Code:
#!/bin/sh

MemFree=`cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//'`
MemBuffers=`cat /proc/meminfo | grep Buffers: | awk '{print $2}' | sed 's/k//'`
MemCached=`cat /proc/meminfo | grep ^Cached: | awk '{print $2}' | sed 's/k//'`
MemTotal=`cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//'`
MemFreePercent=$((100 * ( $MemFree + $MemBuffers + $MemCached ) / $MemTotal ))

echo "Free RAM: $MemFreePercent%";
LOL, I'm turning into a n00b, I just used the graphical system monitor. Yeah, nearly all of my memory is being used but even after opening a bunch of applications I never dip into swap. Linux is really good at managing resources so if the system has a lot of memory then swap shouldn't be used unless for some reason it absolutely needs to be used.

I think when I first started using Linux swap was rarely ever used then either and that was more 10 or so years ago.
 
Last edited by a moderator:
I think the most ideal setup would be to have a separate, class 6+ 1gb card to use as needed for swap. Maybe some fancy rigging to automatically recognize it as swap, so ejecting/inserting it would change the swapon/swapoff setting, possibly based on the label or something.
All I would want it for would be hibernation, and that might not be necessary/practical on Pandora. Anything developed for Pandora that needs a great load of memory should probably be redeveloped.... But for low performance apps like OpenOffice, it could work.
 
You can always have best of both worlds, instead of making a partition to be used as swap, you can always just use a swapfile. This would allow you to either enlarge it when necessary or just keep adding small ones as desired. Also nice if you want to switch out SD cards or partitions.

(1) $ mkdir /swap
(2) $ dd if=/dev/zero of=/swap/128mb bs=1024 counts=131072
(3) $ mkswap -L SWAP128MB /swap/128mb
(4) $ swapon /swap/128mb
(5) $ echo "/swap/128mb none swap sw 0 0" >> /etc/fstab

Step (5) sets swap during boot.
Repeat(2), (3), (4), and (5) to add or enlarge as needed. counts = (size in MB) * 1024
 
SD seems too slow to use as swap files. Esp on things like a class2 and other cheapies..
 
@Eet

Don't worry too much. Swap is really only being suggested here. It is far from necessary for regular use. Just look at all the pandora vids! No swap there as far as I'm aware.
 
Eet said:
Personally, I really hope that one isn't required, as I'd hate to sacrifice an SD slot and an SD card to enable it. Still, that'd be preferable to the swap space residing on the Pandora's built-in NAND :).

I thought the NAND wasn't meant for R/W access (write a few times, read many - writing to the NAND a lot can lessen its lifespan)?

____

I'd probably use an SD card and use dedicated swap file, but only if it was needed (in that case a 2-4GB CL6 card) since you'll never know - I'll only keep everything important on one card anyway. Then again, devs should get into proper programming etiquette and not have sloppy programming (read: memory leaks) to begin with.

_____
 
Last edited by a moderator:
Swap files I hear get poorer performance compared to swap partitions, and in this case, you'd want the least bottleneck you can, so the dedicated 2GB card idea sounds optimal in this case.
 
On second thought, even if the devs programming certain programs are using 100% "clean" code, there are certain factors, or instances where SWAP could be of use:

- 3D modeling (I'm doubtful of rendering anything on the Panda tho, but then again older early-90's computers could do some 3D animation)... if someone decides to port their own variant of Blender for example, I'm certain it could use that space for textures, maps, etc.

- Drawing/Sketching/editing programs (GIMP, etc.)

- Music creation, audio tracks, sampling (raw audio samples are/can be large), etc.
 
paulguy said:
Swap files I hear get poorer performance compared to swap partitions,
It used to be like that, but not for since some years ago, according to what I've been told. It's simple, really. The system figures out the low-level sectors and addresses them, instead of going through the filesystem layer. Thus, it'll be used just as if it were a partition.
(On a real disk it would matter if your filesystem had become fragmented, but for an SD card it shouldn't matter). So, the short of it is that swap files should be as fast as partitions.

and in this case, you'd want the least bottleneck you can, so the dedicated 2GB card idea sounds optimal in this case.
Well, as far as I understand the device can really handle only one card at the time anyway.. but what matters more is that if the swap speed turns out to be really critical for you then what you need is more RAM (or more efficient applications), not fast swap. Swap is useful for the occasional overflow of available RAM (because it's better to swap a little bit every forthnight instead of going down in flames just because you happened to point your browser to an image-heavy site).

-Tor
 
Last edited by a moderator:
Back
Top