1# fieldnull 2 3fieldnull is a JVMTI agent designed for testing for a given field the number of 4instances with that field set to null. This can be useful for determining what 5fields should be moved into side structures in cases where memory use is 6important. 7 8# Usage 9### Build 10> `m libfieldnull libfieldnulls` 11 12The libraries will be built for 32-bit, 64-bit, host and target. Below examples 13assume you want to use the 64-bit version. 14 15### Command Line 16 17The agent is loaded using -agentpath like normal. It takes arguments in the 18following format: 19> `Lname/of/class;.nameOfField:Ltype/of/field;[,...]` 20 21#### ART 22> `art -Xplugin:$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so '-agentpath:libfieldnull.so=Lname/of/class;.nameOfField:Ltype/of/field;' -cp tmp/java/helloworld.dex -Xint helloworld` 23 24* `-Xplugin` and `-agentpath` need to be used, otherwise the agent will fail during init. 25* If using `libartd.so`, make sure to use the debug version of jvmti. 26 27> `adb shell setenforce 0` 28> 29> `adb push $ANDROID_PRODUCT_OUT/system/lib64/libfieldnulls.so /data/local/tmp/` 30> 31> `adb shell am start-activity --attach-agent '/data/local/tmp/libfieldnulls.so=Ljava/lang/Class;.name:Ljava/lang/String;' some.debuggable.apps/.the.app.MainActivity` 32 33#### RI 34> `java '-agentpath:libfieldnull.so=Lname/of/class;.nameOfField:Ltype/of/field;' -cp tmp/helloworld/classes helloworld` 35 36### Printing the Results 37All statistics gathered during the trace are printed automatically when the 38program normally exits. In the case of Android applications, they are always 39killed, so we need to manually print the results. 40 41> `kill -SIGQUIT $(pid com.littleinc.orm_benchmark)` 42 43Will initiate a dump of the counts (to logcat). 44 45The dump will look something like this. 46 47> `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:96] Dumping counts of null fields.` 48> 49> `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:97] Field name null count total count` 50> 51> `dalvikvm32 I 08-30 14:51:20 84818 84818 fieldnull.cc:135] Ljava/lang/Class;.name:Ljava/lang/String; 5 2936` 52