???????????????????????????????Memory?У?
public class SomeMemoryObject {
private final static int someLong_OFFSET = 0;
private final static int someInt_OFFSET = 8;
private final static int SIZE = 8 + 4; // one long + one int
private long address;
private final Memory memory;
public SomeMemoryObject(Memory memory) {
this.memory = memory;
this.address = memory.alloc(SIZE);
}
@Override
public void finalize() {
memory.free(address);
}
public final void setSomeLong(long someLong) {
memory.putLong(address + someLong_OFFSET?? someLong);
}
public final long getSomeLong() {
return memory.getLong(address + someLong_OFFSET);
}
public final void setSomeInt(int someInt) {
memory.putInt(address + someInt_OFFSET?? someInt);
}
public final int getSomeInt() {
return memory.getInt(address + someInt_OFFSET);
}
}
??????????????????????????????д???????????????????????SomeObject??????????????????????SomeMemoryObject????
// with JIT:
Number of Objects:  1??000     1??000??000     10??000??000    60??000??000
Heap Avg Write:      107         2.30          2.51         2.58
Native Avg Write:    305         6.65          5.94         5.26
Heap Avg Read:       61          0.31          0.28         0.28
Native Avg Read:     309         3.50          2.96         2.16
// without JIT: (-Xint)
Number of Objects:  1??000     1??000??000     10??000??000    60??000??000
Heap Avg Write:      104         107           105         102
Native Avg Write:    292         293           300         297
Heap Avg Read:       59          63            60          58
Native Avg Read:     297         298           302         299
????????????JVM??????????????????????????Java???е??????10??????????д???????????2??????????????????????????SomeMemoryObject???????????????????????????????д?????????????????????????????????????д?????????????????
??????????????????????
?????????????????к?????????????????а???????????????????????????????ε??д???????????????????????????Щ????????????????????
// with JIT and sequential access:
Number of Objects:  1??000     1??000??000     1??000??000??000
Heap Avg Write:      12          0.34           0.35
Native Avg Write:    102         0.71           0.69
Heap Avg Read:       12          0.29           0.28
Native Avg Read:     110         0.32           0.32
// without JIT and sequential access: (-Xint)
Number of Objects:  1??000     1??000??000      10??000??000
Heap Avg Write:      8           8              8
Native Avg Write:    91          92             94
Heap Avg Read:       10          10             10
Native Avg Read:     91          90             94
// with JIT and random access:
Number of Objects:  1??000     1??000??000     1??000??000??000
Heap Avg Write:      61          1.01           1.12
Native Avg Write:    151         0.89           0.90
Heap Avg Read:       59          0.89           0.92
Native Avg Read:     156         0.78           0.84
// without JIT and random access: (-Xint)
Number of Objects:  1??000     1??000??000      10??000??000
Heap Avg Write:      55          55              55
Native Avg Write:    141         142             140
Heap Avg Read:       55          55              55
Native Avg Read:     138         140             138
????????:????????????????Java?????????????????????????????????????????????????????????????????????????????????????????????
??????????
??????Java????????????????????壬???統(tǒng)????????????????(>2G)????????????????????(GC)?????????????????????????????治??????Java????????????????е???????????JVM?????????п???????????????????????????ByteBuffer??????á???????ByteBuffer????????????????????Щ??棬???????????????????????????IO???в?????