Re: Why does NIO buffer have to be direct?
Posted by
Michael Bien on
Jun 15, 2011; 5:07pm
URL: https://forum.jogamp.org/Why-does-NIO-buffer-have-to-be-direct-tp3068140p3068294.html
On 06/15/2011 06:44 PM, barno [via jogamp] wrote:
>
> When using a non-direct NIO buffer I get an IllegalArgumentException: buffer
> is not direct
>
> Why is it not possible to use a non direct buffer?
>
>
hi barno,
most of the api only allows direct buffers for performance reasons
(primarily the command queue and all memory objects).
direct memory never moves in the heap which means jocl doesn't have to
interfere with the gc (critical locks) or copy objects before passing
the memory as pointer to OpenCL. Regular heap allocated buffers are
basically arrays which behave like normal objects. The GC may defragment
or just move the objects around in the heap (e.g new to old gen)...
using pointers without expensive locks wouldn't be a good idea under
those conditions.
if you are using lots of small buffers and worry about allocation
performance take a look at CachedBufferFactory.
regards,
michael
--
http://michael-bien.com/