https://issues.apache.org/bugzilla/show_bug.cgi?id=44769


Mladen Turk <[EMAIL PROTECTED]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




--- Comment #1 from Mladen Turk <[EMAIL PROTECTED]>  2008-04-07 12:05:02 PST ---
This looks pretty usable.
It's a simple call to NewDirectByteBuffer

Think it can be done in one call, I mean
allocation and creation of ByteBuffer (much faster)

so

ByteBuffer bb = Stdlib.newDirectByteBuffer(size)
...
Stdlib.freeByteBuffer(bb)

Of course other option would be to use single Stdlib.malloc
of higher size and then create ByteBuffers on slices.

So this

long addr = Stdlib.malloc(1024 * 16)

ByteBuffer bba = Stdlib.asByteBuffer(addr, 1024);
ByteBuffer bbb = Stdlib.asByteBuffer(addr + 1024, 1024);

...
Stdlib.free(addr)

has meaning only if you need to have addr of longer
life then ByteBuffer and you wish to have your
memory manager, which can be very useful in case
you need to create/destroy many objects (malloc is time expensive).

In other case the first one will do.
A Stdlib.getByteBufferAddress(bb) will return the memory
that you can use with Stdlib.memread, memset, etc.

Think I'll implement all options


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to