Get more RAM and faster responses by disabling verify-bytecode!

Did you find this post useful?

  • Yes!

    Votes: 158 87.3%
  • No.

    Votes: 23 12.7%

  • Total voters
    181
Search This thread

nibras_reeza

Senior Member
Feb 8, 2011
852
415
Colombo
nibras.co.cc
Here's a little tip that would give you more RAM on your device.

AS WITH ANY MODDING PROCEDURE FOR YOUR PHONE, THIS GUIDE ALSO COMES WITH NO WARRANTY. AUTHOR HOLDS NO RESPONSIBILITY FOR ANY DIRECT AND INDIRECT CONSEQUENCES OF FOLLOWING THIS GUIDE. MAKE SURE YOU HAVE MADE A NAND BACKUP BEFORE PROCEEDING.

This is not useful in odexed ROMs & devices with 1GB or more RAM. However, this will give a performance boost in deodexed ROMs as much as odexing system & data apps. This is an alternative for odexing. It's not that you can't apply this tweak on an odexed ROM but rather, it's useless to do so.

1) Open Terminal Emulator on phone or adb shell from PC and type the following.
su
setprop dalvik.vm.verify-bytecode false
setprop dalvik.vm.dexopt-flags v=n,o=v
rm /data/dalvik-cache/*
rm /cache/dalvik-cache/*
reboot


2) Add these to the /data/local.prop or build.prop.
dalvik.vm.verify-bytecode = false
dalvik.vm.dexopt-flags=v=n,o=v

(Copy local.prop or build.prop to SD and edit them. Copy back afterwards. If lines starting with dalvik.vm.verify-bytecode or dalvik.vm.dexopt-flags exist already, please modify them as above. Also type following in adb shell or terminal emulator.
rm /data/dalvik-cache/*
rm /cache/dalvik-cache/*
reboot


Advantages:
  • More free RAM.
  • Faster launch for system & user apps during the second launch.
  • Gives as much as of a performance boost as ODEX without odexing. Themer friendly.
  • Smoother app switching.

Disadvantages:
  • Might break some apps.

You can read more information about this on here and here.


Thanks to Danzano for testing this tweak in advance.

Reversing the change/undo tweak.
Type the following in shell.
su
setprop dalvik.vm.verify-bytecode true
rm /data/dalvik-cache/*
rm /cache/dalvik-cache/*
reboot
 
Last edited:

nibras_reeza

Senior Member
Feb 8, 2011
852
415
Colombo
nibras.co.cc
Sounds really awesome, probably would try it. hmm... one concern, would it mess the os config.?
OS config in the sense? If you are talking about parameters given to Android in build.prop and stuff like that, it is both an yes and no.

bytecode-verify is an important dalvik-vm parameter and so, it will change the OS config for byte-code verify ONLY. Other parameters will not change.

You can undo this with,
su
setprop dalvik.vm.verify-bytecode true
rm /data/dalvik-cache/*
rm /cache/dalvik-cache/*
reboot
 

VeEuzUKY

Senior Member
Oct 10, 2008
1,314
128
Could you create a script to apply this fo the less proficient in these matters such as me?

Thanks for sharing! Great job!!:)
 

nibras_reeza

Senior Member
Feb 8, 2011
852
415
Colombo
nibras.co.cc
Someone knows of this work?

Sent from my HTC Bliss using XDA Premium App
Worked for me and Danzano. Try it and post your results.

Could you create a script to apply this fo the less proficient in these matters such as me?

Thanks for sharing! Great job!!:)
Hmm, only 5 lines of code? Open up terminal emulator and type the 5 lines starting with SU and ending with reboot.

What about the start and stop command?
Huh?

---------- Post added at 11:20 PM ---------- Previous post was at 11:19 PM ----------

it's good for htc Sensation ?? sensation have 768MB RAM
Not sure. Give it a go. You can easily undo.
 

KCRic

Senior Member
Aug 4, 2010
1,230
268
Overland Park
Might try this on my G2 - can't hurt to try for a bit.

Just wondering exactly what verify bytecode does for the dalvik-vm. Is it there to ensure data integrity, checking for errors and such? Is it sort of like what ECC is for RAM but for the dalvik-vm?
 
  • Like
Reactions: nibras_reeza

alroger

Senior Member
May 19, 2011
1,299
1,937
Deerfield Beach
OnePlus 6
Moto G Stylus 5G
no dalvik.vm.verify-bytecode here

Hmmm, I think I dont have that prop here... getprop dalvik.vm.verify-bytecode returns nothing to me. Imediatly after boot caches come back and grow...

This is after a reboot
Code:
~ # du -hs /cache/dalvik-cache/ /data/dalvik-cache/
29.0M	/cache/dalvik-cache/
23.5M	/data/dalvik-cache/
~ # getprop dalvik.vm.verify-bytecode

But the idea is interesnting.
 

nibras_reeza

Senior Member
Feb 8, 2011
852
415
Colombo
nibras.co.cc
Might try this on my G2 - can't hurt to try for a bit.

Just wondering exactly what verify bytecode does for the dalvik-vm. Is it there to ensure data integrity, checking for errors and such? Is it sort of like what ECC is for RAM but for the dalvik-vm?

An in-depth discussion has been linked at the bottom of OP. It simply makes Android ignore any possible errors in code & proceed directly to compile all classes. It also forces to compile some unsafe code. And, yes, it's mainly there to check for errors I'd say. The process is very similar to odexing with dexopt. It forces DVM to make some unsafe assumptions which dexopt makes by default. This is not very different from odexing in terms of the byte code produced.

Hmmm, I think I dont have that prop here... getprop dalvik.vm.verify-bytecode returns nothing to me. Imediatly after boot caches come back and grow...

This is after a reboot
Code:
~ # du -hs /cache/dalvik-cache/ /data/dalvik-cache/
29.0M	/cache/dalvik-cache/
23.5M	/data/dalvik-cache/
~ # getprop dalvik.vm.verify-bytecode

But the idea is interesnting.

This would not do anything at all to the caches. They will be reproduced after reboot. It just changes the bytecode pattern in dex/odex files. Perhaps, the cache might even be slightly bigger with this code.

Can you try dalvikvm -help and post the output? If you are in root mode, the getprop should either return a true or false. What version/device are you using?
 

alroger

Senior Member
May 19, 2011
1,299
1,937
Deerfield Beach
OnePlus 6
Moto G Stylus 5G
no dalvik.vm.verify-bytecode

This would not do anything at all to the caches. They will be reproduced after reboot. It just changes the bytecode pattern in dex/odex files. Perhaps, the cache might even be slightly bigger with this code.

Can you try dalvikvm -help and post the output? If you are in root mode, the getprop should either return a true or false. What version/device are you using?

[TAB] Samsung Galaxy Tab P1000N
[ROM] CM7 Beta KANG 2011-06-16 by Technomancer
[KERNEL] CM7 #20110911 by HumberOS

Txt attached.

- XDA Premium App - SGT-P1000N CM7 Beta KANG
 

Attachments

  • dalvikvm.txt
    1.6 KB · Views: 268
Last edited:

fLipz

Senior Member
Oct 27, 2008
715
1,125
14° 35' N, 120° 59' E
Originally Posted by fLipz View Post

What about the start and stop command?

Huh?


i read here it says

from netmite
Remember to stop and restart the runtime (adb shell stop; adb shell start).

do we still need to type at the Terminal Emulator the Command Start and Stop after we type the code?

and here's also my output
z71 Variant
CM7 182 Nightly Build
# dalvikvm -help
dalvikvm -help

dalvikvm: [options] class [argument ...]
dalvikvm: [options] -jar file.jar [argument ...]

The following standard options are recognized:
-classpath classpath
-Dproperty=value
-verbose:tag ('gc', 'jni', or 'class')
-ea[:<package name>... |:<class name>]
-da[:<package name>... |:<class name>]
(-enableassertions, -disableassertions)
-esa
-dsa
(-enablesystemassertions, -disablesystemassertions)
-showversion
-help

The following extended options are recognized:
-Xrunjdwp:<options>
-Xbootclasspath:bootclasspath
-Xcheck:tag (e.g. 'jni')
-XmsN (min heap, must be multiple of 1K, >= 1MB)
-XmxN (max heap, must be multiple of 1K, >= 2MB)
-XssN (stack size, >= 1KB, <= 256KB)
-Xverify:{none,remote,all}
-Xrs
-Xint (extended to accept ':portable', ':fast' and ':jit')

These are unique to Dalvik:
-Xzygote
-Xdexopt:{none,verified,all}
-Xnoquithandler
-Xjnigreflimit:N (must be multiple of 100, >= 200)
-Xjniopts:{warnonly,forcecopy}
-Xjnitrace:substring (eg NativeClass or nativeMethod)
-Xdeadlockpredict:{off,warn,err,abort}
-Xstacktracefile:<filename>
-Xgc:[no]precise
-Xgc:[no]preverify
-Xgc:[no]postverify
-Xgc:[no]concurrent
-Xgc:[no]verifycardtable
-Xgenregmap
-Xcheckdexsum
-Xincludeselectedop
-Xjitop:hexopvalue[-endvalue][,hexopvalue[-endvalue]]*
-Xincludeselectedmethod
-Xjitthreshold:decimalvalue
-Xjitblocking
-Xjitmethod:signature[,signature]* (eg Ljava/lang/String\;replace)
-Xjitcheckcg
-Xjitverbose
-Xjitprofile
-Xjitdisableopt

Configured with: debugger profiler hprof jit(armv6-vfp) show_exception=1

Dalvik VM init failed (check log file)
#


thank you!
 
Last edited:

jikantaru

Senior Member
Jun 20, 2011
290
376
Thanks for sharing, I tried it but only this part doesn't work

rm /cache/dalvik-cache/* no such directory.

I think it speed my phone a little, can I ask to is this compatible with V6 supercharger?

Thanks again. :)
 

nibras_reeza

Senior Member
Feb 8, 2011
852
415
Colombo
nibras.co.cc
[TAB] Samsung Galaxy Tab P1000N
[ROM] CM7 Beta KANG 2011-06-16 by Technomancer
[KERNEL] CM7 #20110911 by HumberOS

Txt attached. --- oops, can't upload from the tab. Looking for anything specific?
Copy/paste for now. I will clean this up later...


dalvikvm: [options] class [argument ...]
dalvikvm: [options] -jar file.jar [argument ...]

The following standard options are recognized:
-classpath classpath
-Dproperty=value
-verbose:tag ('gc', 'jni', or 'class')
-ea[:<package name>... |:<class name>]
-da[:<package name>... |:<class name>]
(-enableassertions, -disableassertions)
-esa
-dsa
(-enablesystemassertions, -disablesystemassertions)
-showversion
-help

The following extended options are recognized:
-Xrunjdwp:<options>
-Xbootclasspath:bootclasspath
-Xcheck:tag (e.g. 'jni')
-XmsN (min heap, must be multiple of 1K, >= 1MB)
-XmxN (max heap, must be multiple of 1K, >= 2MB)
-XssN (stack size, >= 1KB, <= 256KB)
-Xverify:{none,remote,all}
-Xrs
-Xint (extended to accept ':portable', ':fast' and ':jit')

These are unique to Dalvik:
-Xzygote
-Xdexopt:{none,verified,all}
-Xnoquithandler
-Xjnigreflimit:N (must be multiple of 100, >= 200)
-Xjniopts:{warnonly,forcecopy}
-Xjnitrace:substring (eg NativeClass or nativeMethod)
-Xdeadlockpredict:{off,warn,err,abort}
-Xstacktracefile:<filename>
-Xgc:[no]precise
-Xgc:[no]preverify
-Xgc:[no]postverify
-Xgc:[no]concurrent
-Xgc:[no]verifycardtable
-Xgenregmap
-Xcheckdexsum
-Xincludeselectedop
-Xjitop:hexopvalue[-endvalue][,hexopvalue[-endvalue]]*
-Xincludeselectedmethod
-Xjitthreshold:decimalvalue
-Xjitblocking
-Xjitmethod:signature[,signature]* (eg Ljava/lang/String\;replace)
-Xjitcheckcg
-Xjitverbose
-Xjitprofile
-Xjitdisableopt

Configured with: debugger profiler hprof jit(armv7-a-neon) show_exception=1

Dalvik VM init failed (check log file)


- XDA Premium App - SGT-P1000N CM7 Beta KANG
Try these,
Run these commands and see what are the default values.
getprop dalvik.vm.Xverify
getprop dalbik.vm.Xdexopt
getprop dalvik.vm.dexopt-flags

Then, try running these if above commands return a value.
setprop dalvik.vm.Xverify none
setprop dalbik.vm.Xdexopt verified
setprop dalvik.vm.dexopt-flags v=n,o=v

It appears your device doesn't seem to have the properties I have changed in this guide. I'm not sure how this will turn out. But, try above commands. Am just making an intelligent guess.

---------- Post added at 03:55 PM ---------- Previous post was at 03:54 PM ----------

i read here it says

from netmite


do we still need to type at the Terminal Emulator the Command Start and Stop after we type the code?

and here's also my output
z71 Variant
CM7 182 Nightly Build



thank you!
Not necessary to restart the shell since we are rebooting the device itself.

---------- Post added at 03:56 PM ---------- Previous post was at 03:55 PM ----------

Thanks for sharing, I tried it but only this part doesn't work

rm /cache/dalvik-cache/* no such directory.

I think it speed my phone a little, can I ask to is this compatible with V6 supercharger?

Thanks again. :)
I don't know. I haven't gone through the full source of super charger. It wouldn't really cause a problem that I can think of. This flag just changes the way Dalvik VM compiles apps. This should not interfere with anything else other than badly coded apps.
 
  • Like
Reactions: fLipz

harunjo

Senior Member
Aug 5, 2009
1,043
1,155
Jakarta
Thanks for sharing, I tried it but only this part doesn't work

rm /cache/dalvik-cache/* no such directory.

I think it speed my phone a little, can I ask to is this compatible with V6 supercharger?

Thanks again. :)

i pair this with v6 supercharger and both is work.

supercharger is for memory management..and this setting is for dalvik management..totally different working area for both setting CMIIW

confirmed work with

Nexus one with SuperOSR ROM

and Samsung Spica i5700 with CM 6.11 froyo ROM

Nice share!
 
Last edited:
  • Like
Reactions: nibras_reeza

Top Liked Posts

  • There are no posts matching your filters.
  • 64
    Here's a little tip that would give you more RAM on your device.

    AS WITH ANY MODDING PROCEDURE FOR YOUR PHONE, THIS GUIDE ALSO COMES WITH NO WARRANTY. AUTHOR HOLDS NO RESPONSIBILITY FOR ANY DIRECT AND INDIRECT CONSEQUENCES OF FOLLOWING THIS GUIDE. MAKE SURE YOU HAVE MADE A NAND BACKUP BEFORE PROCEEDING.

    This is not useful in odexed ROMs & devices with 1GB or more RAM. However, this will give a performance boost in deodexed ROMs as much as odexing system & data apps. This is an alternative for odexing. It's not that you can't apply this tweak on an odexed ROM but rather, it's useless to do so.

    1) Open Terminal Emulator on phone or adb shell from PC and type the following.
    su
    setprop dalvik.vm.verify-bytecode false
    setprop dalvik.vm.dexopt-flags v=n,o=v
    rm /data/dalvik-cache/*
    rm /cache/dalvik-cache/*
    reboot


    2) Add these to the /data/local.prop or build.prop.
    dalvik.vm.verify-bytecode = false
    dalvik.vm.dexopt-flags=v=n,o=v

    (Copy local.prop or build.prop to SD and edit them. Copy back afterwards. If lines starting with dalvik.vm.verify-bytecode or dalvik.vm.dexopt-flags exist already, please modify them as above. Also type following in adb shell or terminal emulator.
    rm /data/dalvik-cache/*
    rm /cache/dalvik-cache/*
    reboot


    Advantages:
    • More free RAM.
    • Faster launch for system & user apps during the second launch.
    • Gives as much as of a performance boost as ODEX without odexing. Themer friendly.
    • Smoother app switching.

    Disadvantages:
    • Might break some apps.

    You can read more information about this on here and here.


    Thanks to Danzano for testing this tweak in advance.

    Reversing the change/undo tweak.
    Type the following in shell.
    su
    setprop dalvik.vm.verify-bytecode true
    rm /data/dalvik-cache/*
    rm /cache/dalvik-cache/*
    reboot
    5
    Is more RAM in Android is good? Cause i read that less ram is not a problem in our devices, it's even better. So maybe disabling verify-bytecode is useless?
    Are you talking about enabling swap? More RAM is always better. Not all apps make good use of application state data.

    Android doesn't have built-in swap. It instead uses a very different technique where when an application is in memory and device runs out of memory, Android stores the state(eg: latitude and longitude of current position in a map or url of the browser) and when this app is launched again, Android passes the state to Android making it appear that the app was always in memory.

    Due to this reason, Android can usually work with low RAM and with no swap. However, having more free RAM will make the device more responsive and making app switching more smoother.

    This mod trades app stability for better performance. With bytecode-verify on, only verified classes are compiled and no unsafe code is executed. This makes the Dalvik VM slightly less efficient. When, you turn this off, Dalvik VM is more efficient but some apps might break.

    In other words, Android Team wanted all apps to run properly. So, they kept bytecode-verify on. Most end users don't care as long as the apps they use work properly. So, having more RAM and a very responsive phone is our priority over app compatibility and stability.
    3
    If anyone wants to try this tweak out but is terminal-dumb, I made a quick script to be run from recovery.

    http://rzdroid.com/ftp/recovery/RZ_dalvik-noverify-update.zip

    It's much easier to just apply an update.zip after installing a ROM if you want to reapply the tweak. :)
    2
    Wow. Will try it

    Sent from my GT-I9100 using XDA App
    2
    As long as dalvik cache is cleared, you are good to go. But,I don't understand why rm /cache/dalvik-cache/* returns an error. Maybe, you used Terminal emulator without root.

    As for those two lines, it's ok to use only the 2nd line. However, I guess you wouldn't loose anything by adding the first line. It's just some phones don't obey the first line and some don't obey the second line. Since, 2nd was already present, probably, your phone obeys it and not the first one.

    hi, nibras... thanks a lot for your nice answer...
    about the error, i don't know exactly what causing it..
    but since the first time i tried to implement this tweak in my Samsung Galaxy GT-i8150, i always follows the guide carefully, that means i always asking for "su" when i using the terminal emulator...
    maybe, just my guess okay, the command rm /cache/dalvik-cache/* returns to error because there is no the dalvik cache under the cache folder in my system.. i recognized it, because i have explored my system using the root explorer, and found there's no dalvik cache in cache folder...
    so, to clear the dalvik cache, i just simply using the option in my CWM recovery mode (typing reboot recovery for the last command in terminal will bring u to recovery mode in instant :) )
    thanks, for this nice tweaks, i'm feel my phone had a little improvement, just more snappier when i open such heavy applications...
    thanks n regards