Deallocate direct NIO buffers
Julien Gouesse
gouessej at yahoo.fr
Fri Aug 5 12:28:04 UTC 2016
I'll use this example from Netty:Use reflection to call cleaner on direct byte buffers in JDK9 by varming · Pull Request #5473 · netty/netty
Best regards
| |
| | | | | | | |
| Use reflection to call cleaner on direct byte buffers in...In JDK9 sun.misc.Cleaner is replaced with java.lang.ref.Cleaner$Cleanable, a class with a method void clean() just like the old cleaner. By using a method reference... |
| |
| Afficher sur github.com | Aperçu par Yahoo |
| |
| |
Le Vendredi 5 août 2016 12h01, Julien Gouesse <gouessej at yahoo.fr> a écrit :
Vladimir,
How can I use java.lang.ref.Cleaner with a direct ByteBuffer? I assume that this kind of buffer still uses jdk.internal.ref.Cleaner internally, I wanted to use this cleaner.
Le Vendredi 5 août 2016 7h30, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> a écrit :
Julien,
There is a public API replacement for sun.misc.Cleaner in 9:
java.lang.ref.Cleaner [1]
Best regards,
Vladimir Ivanov
[1] https://bugs.openjdk.java.net/browse/JDK-8138696
On 8/4/16 5:09 AM, Julien Gouesse wrote:
> Hi
> The class sun.misc.Cleaner was moved into the package jdk.internal.ref in the module jdk.unsupported and I have to use a command line switch or another mean to add an export to this module to avoid getting a java.lang.reflect.InaccessibleObjectException. I could use a NativeScope in a source code compatible with Java 1.9 and later but I need to find a solution working both with Java 1.8 and Java 1.9. Christoph Engelbert mentioned the class AutoCleaning here:http://www.slideshare.net/ChristophEngelbert/a-postapocalyptic-sunmiscunsafe-world#94What is the right way to release the native memory allocated by a direct NIO buffer without using any internal API in Java 1.9 and later? I need an explicit mechanism that calls Cleaner.clean() somehow. In which package can I find the class AutoCleaning? Best regards.
>
More information about the panama-dev
mailing list