Questions tagged [direct-buffer]

In Java, direct buffer is usually used with channels and native I/O routines. It's out of JVM heap and gc operation. It's more expensive to create than non-direct buffer, and better create for large and long-live buffer. The io operation could be better on direct buffer than non-direct buffer, though it's platform and jvm implementation dependent.

12 questions
9
votes
1 answer

Java - When does direct buffer released?

Since it's out of jvm heap & gc, when does it released? Or, it remain until process termination? I already checked: how to garbage collect a direct buffer java Deallocating Direct Buffer Native Memory in Java for JOGL ByteBuffer.allocate() vs.…
Eric
  • 22,183
  • 20
  • 145
  • 196
8
votes
3 answers

cannot access a member of class java.nio.DirectByteBuffer (in module java.base) with modifiers "public"

Got a project which is built to still support Java 6. The code below is inside a jar file built with Compiler compliance level 1.6 That jar file should be called from java apps built for java 6 or newer. It runs fine in Java 8 as well. Now with…
datafiddler
  • 1,755
  • 3
  • 17
  • 30
1
vote
1 answer

Direct Buffer used by ByteBuf is not fully released

I am using Netty 4.1.17-Final with Direct Buffer. We send and receive 100 MB of byte[] in the test program, and when decoder reaches 100 MB, we discard it without doing anything. @Override public void decode(ByteBuffer _in, List _out) { …
nikai
  • 27
  • 1
  • 6
1
vote
2 answers

Releasing a direct buffer in java and possible pitfalls

we have the following piece of code: long buffer = ((DirectBuffer) ByteBuffer.allocateDirect(256)).address(); It seems that there is no reference to direct buffer (as an object) on the thread's stack. So, it means that that object is…
Gilgamesz
  • 4,727
  • 3
  • 28
  • 63
1
vote
2 answers

Java direct ByteBuffer - decode the characters

I would like to read the bytes into the direct ByteBuffer and then decode them without rewrapping the original buffer into the byte[] array to minimize memory allocations. Hence I'd like to avoid using StandardCharsets.UTF_8.decode() as it…
David Siro
  • 1,826
  • 14
  • 33
0
votes
0 answers

Reuse the same IntBuffer object to wrap a different Bytebuffer

I need to get a view of a ByteBuffer b using the same object IntBuffer viewBuffer without having to instantiate a new object every time the reference to the ByteBuffer changes. // An external ByteBuffer ByteBuffer b1 = ByteBuffer.allocateDirect(1024…
PhiloJunkie
  • 1,111
  • 4
  • 13
  • 27
0
votes
2 answers

How to release Pooled direct ByteBuf in netty when written after by ChannelHandlerContext?

In my c/s project, c/s need to exchange fixed-size message with netty. I use pooled direct buffer to buffer message. Code just like below: public void channelRead(ChannelHandlerContext ctx, Object msg) { ByteBuf in = (ByteBuf) msg; try { …
shanfeng
  • 503
  • 2
  • 14
0
votes
0 answers

jconsole could not relfect usage of non-heap memory

I use ByteBuffer.allocateDirect(int) to allocate direct buffer(100M) on non-heap space until java.lang.OutOfMemoryError: Direct buffer memory error thrown. But when I use jconsole to monitoring the non-heap memory usage, no direct buffer used memory…
Machi
  • 403
  • 2
  • 14
0
votes
2 answers

Direct buffer memory issue in Mule - CloudHub RunTime

im facing issue with java.lang.OutOfMemoryError : Direct buffer memory while running the application in Cloud-Hub. here i'm trying to fetch the data from Oracle DB which has 25K records from Inbound table with 1vCore The error occurred after all the…
Karthik
  • 11
  • 4
0
votes
2 answers

DirectBuffer, deallocation

I allocated a direct buffer: ByteBuffer directBuffer = ByteBuffer.allocateDirect(1024); I've read that: Deallocating Direct Buffer Native Memory in Java for JOGL but it doesn't answer directly. To summarize: GC releases a directbuffer when GC…
Gilgamesz
  • 4,727
  • 3
  • 28
  • 63
0
votes
1 answer

How do I correctly work with ByteToMessageCodec.encode and direct buffers

I use a ByteToMessageCodec in my netty project. The encode has the following structure: protected abstract void encode( ChannelHandlerContext ctx, I msg, ByteBuf out ) throws Exception In my case the msg is a message that holds a…
0
votes
0 answers

Direct frame buffer access using OpenCL and SWT

I've written an OpenCL-kernel (JOCL) which takes a few hundred megabytes of input data and produces a viewport-friendly RGB-Image as result. This image shall be presented in an SWT-GUI with a refresh rate of about at least 10 fps to allow realtime…
Kai Giebeler
  • 517
  • 6
  • 12