2009

iPhone Virtual Memory: Speed Boost For Your iPhone. Know The Risks

Support FSMdotCOM - become Pro and we can ditch the ads

A few days ago, we presented you a tweak to free iPhone’s RAM memory called iPhoneVM. Basically this tweak creates a swap file to keep the less important processes of the iPhone, and by doing that you would get get better performance in terms of speed.

A reader of the site, warned us in the comments that this might damage the iPhone, but i decided to let it go until i do some research. Turns out he was 110% right, and the guys over at xsellize have a huge thread on the matter.

Warning: This article is HUGE. I mean it! If you care about your iPhone, you might just spend the time, and read it. Get to know the risks that virtual memory presents and decide if you are willing to to continue using it or not.

What is VM?
Virtual Memory, or VM, is exactly what it sounds like. Its virtual memory. Instead of using just the internal RAM, both of these methods create Swap Files on your Flash Drive (your iPhone “hard drive”) and uses that file as extra RAM. To read more about VM, click here

What are the Risks?
The risks that I and others see are that eventually both methods may cause your iPhone’s Flash Memory to fail due to the excessive read/write. Below is some info that others have posted.

Originally Posted by who
it WILL decrease the life of the flash memory. you see, ram was designed to be abused (frequent i/o writes and so on), but the memory that holds your data wasnt really designed to do the same. it was make to store the data for long periods of time. eventually, some sectors WILL give out, but i doubt it would be anytime soon.

Originally Posted by who
it will kill it, but only within, what, FIVE years? :| just get it. if you have it, use it. it’s my saying. you could die tomorrow, for all you know. i’ve flashed so many different firmwares, im pretty suprised its’ not even slowing down yet. it’s built rigidly, so dont be afraid to go outside the box. apple builds quality products.

Originally Posted by chung15673
Yup, I am skeptical myself because if it is that simple then why didn’t Apple do this? It is very easy to dedicate a block of flash memory for this specific purpose without harming the rest of the user’s flash memory.

Virtual memory is not exactly a novel idea and most older technologies are trying to move away from it.

Originally Posted by SecretSociety
I dont think creating a virtual memory will harm any hardware, this technique was formulated to make the computer or in this case your phone not to crash by creating extra memory.

The logic on “killing your hard drive faster by using this mod” is just the same with how frequent you use your car. The more often you use your car, the faster it wears down. If you dont use it, then where’s the fun in that?

All im saying is that our hardwares are built to take a beating, so go ahead and enjoy it, take it to the fullest and just have fun playing with your toy. Im doing it.

Originally Posted by antonioj
The new nokia n900 uses the same kind of process. It has 256mb of RAM plus a 1gb swapfile (virtual RAM). So all that talk about damaging the flash…well…

Originally Posted by briviao
Wikipedia says that a NAND Flash memory can be overwritten more than 1.000.000 times (should be even more on new flash memories).
Now the problem is to estimate the frequency of memory-overwriting on the iPhone. This is a tricky part!

Which One is For Me / Whats the Difference Between the Two?
That’s your choice…

  • The chinese version creates one large swap file ( 256MB ) and uses that space as needed.
  • The .plist version creates a smaller swap file ( 64MB ) and creates / deletes the swap files as needed. Below is some info on the differences

Originally Posted by stinky1
Here’s the answer! (how do you like that for pompous!!)

*****************

After a little more digging I’ve confirmed the chinese version is nothing special. It has two plists and two other files

The file vm is actually the dynamic pager file in sbin. I did a binary compare, no difference
The file fm is actually bigboss’s freemem file from sbsettings. Rude to steal with no notice.

The other two plists are no big whoop, they’ve been discussed.

In sum: just tweak the plist and install it. There is nothing dangerous in the chinese package, but nothing that you need either.

*************************

Originally Posted by MultiplicatePorDevNull
So the chinese method use an auto “freememory tweak” (very useful, but pretty sure that its execution is the “lag moments” that some people said on chinese method) and this plist method not? But this plist method “cleans” the memory then? Or simply it doesnt need it? Why?

Originally Posted by stinky1
i THINK that is what’s happening – it runs a freememory cycle which causes a lag and also isn’t necessary. also having the OnDemand key set to true MAY cause a lag as well.

I do not KNOW what is happening. just guessing. I just use my plist, load up mail, safari, ipod, run freemem through sbs.

I then have mail, phone, safari and ipod all running in the background with 70MB shown free. There are occasional brief lags, but when it’s not lagging it seems faster. On the whole, very happy with this tweak.

Originally Posted by devein
they are really the same commands, but used with different options:

1) chinese method
package iphonevm from http://repo.beyouriphone.com/ repository

this package has:
dpkg -L com.beyoip.iphonevm

/sbin/fm
/sbin/vm
/System/Library/LaunchDaemons/com.apple.fm.plist
/System/Library/LaunchDaemons/com.apple.vm.plist

invoking the /vm file from shell
/sbin/vm –help
/sbin/vm: illegal option — –
usage: dynamic_pager [-F filename] [-L low water alert trigger] [-H high water alert trigger] [-S file size] [-P priority]

this really is a dynamic_pager command. this file exists already in /sbin/dynamic_pager

diff /sbin/dynamic_pager /sbin/vm – doesnt show any differences so this is exactly the same file

contents of /System/Library/LaunchDaemons/com.apple.vm.plist

Label
com.apple.vm
Program
/sbin/vm
ProgramArguments

/sbin/vm
-S
268435456

RunAtLoad

OnDemand

so, this method calls /sbin/vm vm -S 268435456 at startup.

there is also the /bin/fm command its function is unknown, im calling anyone who can identify this binary

im /System/Library/LaunchDaemons/com.apple.fm.plist

Label
com.apple.fm
Program
.//sbin/fm
ProgramArguments

.//sbin/fm

RunAtLoad

OnDemand

running this command:
~ root# /sbin/fm asd
2009-10-02 13:50:17.154 fm[1221:903] Processing 51277824 bytes

it has created swap file:
ls -lh /private/var/vm/swapfile0
-rw——T 1 root wheel 64M Oct 2 13:43 /private/var/vm/swapfile0

2) “plist” method

using plist editor: main part of file:
/sbin/dynamic_pager
-F
/private/var/vm/iphone_swap

so it calls /sbin/dynamic_pager -F /private/var/vm/iphone_swap
(-F option specifies swap file name)

——————————————————-

documentation of this command:

http://developer.apple.com/mac/libra…c_pager.8.html

ive also found this interesting bit of information, it is about macosx system where this command is also used:
http://www.omnigroup.com/mailman/arc…er/042021.html

so, “chinese” method calls for a fixed size swap, and “plist” method uses the same command, but the swap file size is created dynamically.

IMHO this dynamic method is more “modern”, but which method is better?
im testing second method now (i’ve had installed chinese package and just edited /System/Library/LaunchDaemons/com.apple.vm.plist to remove “-S” argument )

so to summarize:

“chinese” method calls dynamic_pager with static swap
“plist” method calls dynamic_pager , by default the swap is dynamic

Further more, stinky1 has modified the .plist to this:

Originally Posted by stinky1
The only major difference I see between the chinese and plist only versions (aside from the vm and fm files, whatever they are is this:

Chinese:
OnDemand

Other:
OnDemand

I do wonder how the Chinese one would operate with this key changed, but I’m just using the plist one for simplicity.

I read here that this command is deprecated, so I added this:
http://developer.apple.com/mac/libra…d.plist.5.html

KeepAlive

I also turned off encryption to enhance speed, giving me this:
Label
com.apple.dynamic_pager
KeepAlive

OnDemand

ProgramArguments

/sbin/dynamic_pager
-F
/private/var/vm/iphone_swap

RunAtLoad

UseEncryptedSwap

Works nicely for me. Creates/destroys 64mb swap files as needed. No need for Safari quitter or manually killing my mail app anymore if I want to play a big game. Occassional lags, but nothing major. SBSettings “Free Up Memory” works just fine; I can load up mail, safari, ipod, and then free up memory to be left with around 75mb showing and very snappy performance.

Overall, very nice. If it kills my ram, oh well, I have applecare.

The choice on which one to use is yours. Try them both if you like (I would suggest not using both at once tho). If you want my opinion, I would suggest the .plist version. From what I have been reading, most people are switching from the chinese one to the .plist one. Also, check my “Personal Experience” below to read why the .plist is currently the choice for me.

Personal Experience / What Others Say:
My personal experience (im running an iPhone 3G on 3.1 – I didn’t do any extra backgrounding/testing, this is all just everyday use):

Originally tried the chinese version. Was liking it but didn’t see great improvements when at idle (maybe got up to high 40’s – low 50’s). Although it did never seem to drop below 30 so it was working for me. Occasionally it did lag, but nothing too bad

After reading more about the .plist version, it seemed people were getting rid of the chinese one and switching to the .plist one so I decided to do that. After install and reboot, I was sitting around low 50’s and i’ve been running and just using it normally and again, it has not dropped below 30 yet which tells me its working. However, I have only just installed this so I have no yet impressions and cant really compare to the chiineese one bc i used the chines one for two days. I will post more after some more usage. After idle for a few minutes, up to low 60’s

Other’s views:

from .plist thread

Originally Posted by brentbizzle
Ok, so I did some basic benchmarking with my iPhone. If you have any questions about my base setup I can address those later, but for the purpose of my testing it really doesn’t matter. Here’s some quick data I collected.

Launch time for SMS app:
3.101
3.048
2.997

SBS free memory between each launch:
7.050
9.981
8.614

Backgrounding weather, facebook, safari, solitaire app; SMS app launch time:
4.416
3.599
3.523
3.587

Backgrounding w/ free memory between each launch:
9.077
8.499
8.348
9.065

That was all before installation. Now here’s post install results

base launch:
2.971
3.035
3.021
2.910

same backgrounding:
3.033
3.085
3.047
2.995
3.021

Heavy backgrounding (added zenbound and space shuttle simulator):
12.983
8.196
8.548
17.034
9.327

I could not test freeing memory between because it takes so long to do so, and the iphone would not be responsive for a while after doing so. Plus sometimes the ram wouldn’t drop below 50 so it wouldn’t allow me to do it.

Looking at the data, with mild backgrounding the VM tool helps! It took the average backgrounding time before install of 3.781 and dropped it to 3.036, which is really the launch time with no backgrounding. Once you do some heavy backgrounding though, performance is not enhanced and is quite irregular.

Visually the slight lag seen with backgrounding under normal circumstances didn’t appear to be there after VM was installed and with the same backgrounding.

Originally Posted by phassat
I’ve tried the chinese one for several days and don’t like it too much…. It is laggy and my games were not smooth as before.
It could make sure that I can launch my games (previously when my memory was low, the games sometimes crashed when it started) but it’s slower….

I use the modified one by stinky1…. and put bitesms, phone, mail, contact, clock in background then I free my mem using sbs… it goes back to 70MB and all the above apps still in background.

It seems that it run smoother compared to the chinese. I will give it a try to my games and report the result… I’m using geochallenge and slugger as the test (geochallenge is quit sometimes without enough mem which was happened before I use the chinese one or this modified one…. Slugger is always run even with smaller memory, but it was laggy using the chinese one)

———- Post added at 11:07 AM ———- Previous post was at 11:00 AM ———-

I’ve tried to run home slugger and it starts very smooth compared to the chinese one…. also when I play the game I couldn’t see a difference with when I run without VM.

So this one is actually much better…. thanks stinky1…
I can’t say about the original plist since I installed stinky1’s to replace the chinese one

Also, after I quit home slugger, memory was 25MB for a second then it goes back to 53MB… and stable in 53MB…..

Originally Posted by mattress
With this virtual memory/swap file plist, I’m able to run all my mobile substrate plugins without the fear of memory intensive apps crashing.

It has made my phone much more stable, and I’m able to keep ‘phone’ ‘mail’ and ‘messages’ app always running in the background, without the fear of cydia or safari or whatever crashing when I need to use it.

I’ve added a few more mobile substrate plugins (Backgrounder, ClockHide, DimDelay, Lockinfo, MailtoAttachment, Popupblocker, preference loader, privacy, reflective dock, rotationinhibitor, winterboard, yourtube, quick reply, libhide), and my phone is still very stable. nothing has crashed on me, and I’m not seeing any hit on performance.

This is the best hack to my phone I’ve done since jailbreaking. I feel apple should have included this from the beginning.

DOWNLOADS
Finally. Enough with the info already…

Here is the Chinese Version:

  • Download the .deb file here: http://www.sendspace.com/file/hatvmw
  • SSH and place the .deb file into directory of choice (i usually use /tmp)
  • Open terminal and navigate to where .deb file is stored on iPhone (ex, use command cd /tmp)
  • Install using command dpkg -i iPhoneVM.deb
  • REBOOT iPhone (turn power off, then back on)
  • Enjoy

Here is the .plist version (modified by stinky1):

  • Download the .plist here: http://www.mediafire.com/?zdezacmq0wm
  • SSH into your iPhone and place the .plist in /System/Library/LaunchDaemons/
  • REBOOT your iPhone (turn power off, then back on)
  • Enjoy.

Uninstall

Chinese Version

  • Open Cydia and uninstall it. (Should be at the very bottom of packages)
  • Now SSH into your iPhone and navigate to var/vm/ and delete the swap files inside. (DO NOT JUST DELETE THE ENTIRE var/vm DIRECTORY – ONLY DELETE THE FILES INSIDE)
  • Now navigate to System/Library/LaunchDaemons and delete the com.apple.dynamic_pager.plist file
  • REBOOT iPhone.
  • Done.

.plist Version

  • SSH into your iPhone and navigate to var/vm/ and delete the swap files inside. (DO NOT JUST DELETE THE ENTIRE var/vm DIRECTORY – ONLY DELETE THE FILES INSIDE)
  • Now navigate to System/Library/LaunchDaemons and delete the com.apple.dynamic_pager.plist file
  • REBOOT iPhone.
  • Done.

Originally Posted by GunHo198
Go to cydia and uninstall the Chinese one. It should be at the bottom of packages. Then ssh and delete the swap file in var/vm. Only delete the swap file. Then go into system/library/launchDaemons and delete the com.apple.dynamic_pager.plist. And reboot.

Sum it all up:
To sum it all up, both methods work but the .plist seems to be the better approach (in my opinion) bc it creates smaller swap files and removes/creates more when needed. I do not think it is wise to use both at the same time. But this is not because I have knowledge about why, only from what I have been reading. (but yet others have used both – so really, im not sure) So pick one and enjoy a little extra boost to your iphone ;)

Most say the VM works, and they see improvements. Few say nothing happens or it causes more lag. My vote goes in the first, I see improvements