|
|
|
|
|
by imtringued
3204 days ago
|
|
It's far from impossible. I would even say it's extremely trivial to add a C++ style delete keyword but then you'd lose memory safety because of the potential use after free bugs and it wouldn't even increase performance because the problem with garbage collectors is the stop the world pause, lack of off heap allocations for very large data and the needed value types to fully take advantage of that feature. If you want manual memory allocation then you should instead look at sun.misc.Unsafe. http://www.docjar.com/html/api/sun/misc/Unsafe.java.html public native long allocateMemory(long bytes);
public native void freeMemory(long address);
Of course you still have to calculate the field offsets and all that stuff manually because it's not a part of the java language but you only asked about the JVM. |
|