• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Enabling SD swap on Galaxo

not sure what you're doing. i was thinking about 2nd line of 'free' output.

[root@galaxy:/]free
total used free shared buffers
Mem: 96568 94824 1744 0 72
Swap: 86836 57292 29544
Total: 183404 152116 31288
[root@galaxy:/]

my swap partition is ~85megs.

oh, and to check that compcache is disabled, check output of 'lsmod'. there shouldn't be ramzswap module listed.
 
Upvote 0
not sure what you're doing. i was thinking about 2nd line of 'free' output.

[root@galaxy:/]free
total used free shared buffers
Mem: 96568 94824 1744 0 72
Swap: 86836 57292 29544
Total: 183404 152116 31288
[root@galaxy:/]

my swap partition is ~85megs.

oh, and to check that compcache is disabled, check output of 'lsmod'. there shouldn't be ramzswap module listed.
i cant do resize in parted while booted into the phone as it says the space is in use (i have music and videos stored in the main partision)
so i did it while in recovery. i clicked cancel as i dont know wtf that means

compcache is not turned on
i havent enabled swap yet as the partision size atm is 32mb (done via recovery before i put media on the card) and it was laggy as hell when i turned on compcache

this is Free
Code:
free
              total         used         free       shared      buffers
  Mem:        95948        91592         4356            0          392
 Swap:            0            0            0
Total:        95948        91592         4356
#

this is my parted print

Code:
Model: SD SU08G (sd/mmc)
Disk /dev/block/mmcblk1: 8169MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      512B    8137MB  8137MB  primary  fat32           lba
 2      8137MB  8169MB  31.9MB  primary  linux-swap(v1)
 
Upvote 0
I turned it off. After watching that Dalvik presentation on Google, it's seems to me that using swap is pointless in Android (I suppose that's why swap support wasn't built in kernel). My experience with swap supports that.

So, Dalvik, it's GC and low memory killer were designed to cope with limited RAM (the goal was around 20MB I think). If you have more RAM than that, it's great, but if you don't have much more (like in Galaxy :) ), swapping doesn't really help. From what I found, not only that it doesn't help, it actually makes things worse. Android application lifecycle is somewhat different than what you might call a "normal" application lifecycle. In Android, an application lives even if its process has been terminated. That means that normally running loads of apps doesn't pose a problem at all because you don't have to have loads of processes alive. But if you use big enough swap, it's unlikely that either of app's processes will ever get killed. And that's a bad thing, because if you try to focus an app which resources are not in RAM, a swap will kick in. And that's slow. It's much quicker to fork a new process and have a (running) app reinitialize itself. And in Android, it supposed to be that way.

So, regardless of what I said earlier, I'll probably won't ever use swap again. :)
 
Upvote 0
then why newer devices are comming out with more and more ram? nexus has four times more ram than galaxy available to kernel. four times. 100 vs 400 megs. when you boot galaxy, all ram is already wasted. to make room for apps, kernel needs to clear cache meaning all changes from default app needs to be recreated. in case of browser, it means reloading from the web (slower than loading from sdcard).
 
Upvote 0
The more RAM, the better. That much is clear. The problem is that memory management doesn't make difference between physical RAM space and swap space. Of course, if you have plenty of RAM, all the better. All I was saying is that you can't really substitute lack of RAM with swap. At most times you are better off without it (swap, not RAM ;) ).

There are always exceptions. Those would be situations when application can't restore its full state (all object that were created before) from local resources and has to use remote resources to fetch them. (like in web browser, what you mentioned, even though browser does cache locally at some extent).

I guess it all boils down to your usage habits and preferences. I seldom use apps like web browser or maps and most of the times when I finish (like, reading a web page) I usually don't need to come back to it (unless I'm interrupted by a phone call, for example). I use lot of gmail, but gmail keeps newer mail cached locally, so starting/switching to it works very fast in every situation (worked a lot slower with swap enabled).

Oh, BTW. What do you mean exactly when you say "kernel needs to clear cache". On what "cache" are you referring to?
 
Upvote 0
This shows the steps and the results from my adventure increasing the swap partition and turning it on. I did that with the device in recovery over adb. Only the last "free" command I did with the phone turned on and connected to the pc with usb debugging on. Hope this helps somebody.

Code:
T:\f.bresslau>adb devices
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
I7500as8rDT4    recovery


T:\f.bresslau>adb shell
/ # su
su


####### Starting parted #######


# parted /dev/block/mmcblk1


####### Checking partition sizes #######


(parted) print
print
print
Model: SD 00000 (sd/mmc)
Disk /dev/block/mmcblk1: 8166MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      32.3kB  8135MB  8135MB  primary  fat32           lba
 2      8135MB  8166MB  31.5MB  primary  linux-swap(v1)



####### Resizing inside parted #######


resize 1 32.3kb 8050mb
resize 2 8050mb 8166mb 


####### Checking the results with print #######


(parted) print
print
print
Model: SD 00000 (sd/mmc)
Disk /dev/block/mmcblk1: 8166MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      32.3kB  8050MB  8050MB  primary  fat32           lba
 2      8050MB  8166MB  116MB   primary  linux-swap(v1)

(parted) quit

Information: You may need to update /etc/fstab.


####### Turning swap on #######


# swapon /dev/block/mmcblk1p2


####### Checking the card's speed (it's a class 6 8GB) #######


# hdparm -t /dev/block/mmcblk1p2

/dev/block/mmcblk1p2:
Timing buffered disk reads:   43 MB in 3.01 seconds = 14627 kB/s

hdparm: HDIO_DRIVE_CMD: Inappropriate ioctl for device

# hdparm -t /dev/block/mmcblk0


/dev/block/mmcblk0:
Timing buffered disk reads:   43 MB in 3.01 seconds = 14604 kB/s

hdparm: HDIO_DRIVE_CMD: Inappropriate ioctl for device



####### checking for swap with free #######

# free
              total         used         free       shared      buffers
  Mem:        94140        92344         1796            0          472
 Swap:       113572         4308       109264
Total:       207712        96652       111060
 
Upvote 0
Hi,
I feel SWAP DOES HELP...if only to save the application state.
I can close my chess and air attack games and when i open they are in the same state as earlier.
But the restoring is as slow as 1st-time opening of an app.
i use a very old(3 eyar old) micro-SD card.

can anyone tell me.....will a class-6 microSD card help speed up the application restoring?

regards
Jeevone
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones