Unsafe.allocateInstance() is implemented in HotSpot VM by directly calling JNI's AllocObject() function [1].<div>An object instance is allocated in the Java heap, but no constructors are invoked for this instance.</div>
<div>This method is mainly used to implement BootstrapConstructorAccessorImpl in the class library.</div><div><br></div><div>Li, what is your original intent for doing explicit memory management in Java?</div><div><br></div>
<div>- Kris<br><div><br></div><div>[1]: <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16337">http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16337</a><br>
<br><div class="gmail_quote">On Fri, Dec 23, 2011 at 7:51 PM, Florian Weimer <span dir="ltr"><<a href="mailto:fweimer@bfk.de">fweimer@bfk.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* Li Li:<br>
<div class="im"><br>
> And I also find a method named allocateInstance, which seems what I<br>
> want.<br>
<br>
</div>allocateInstance() allocates objects on the Java heap, just like new.<br>
I'm pretty sure that there is no way at all to allocate instances<br>
which are not on the Java heap and subject to garbage collection.<br>
<font color="#888888"><br>
--<br>
Florian Weimer <<a href="mailto:fweimer@bfk.de">fweimer@bfk.de</a>><br>
BFK edv-consulting GmbH <a href="http://www.bfk.de/" target="_blank">http://www.bfk.de/</a><br>
Kriegsstraße 100 tel: +49-721-96201-1<br>
D-76133 Karlsruhe fax: +49-721-96201-99<br>
_______________________________________________<br>
hotspot-gc-use mailing list<br>
<a href="mailto:hotspot-gc-use@openjdk.java.net">hotspot-gc-use@openjdk.java.net</a><br>
<a href="http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use" target="_blank">http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use</a><br>
</font></blockquote></div><br></div></div>