Do I need to un-bind an image after using Context#bindImage?

I’m programming OpenCL and map textures directly to OpenCL memory. For this I’m using the following logic:

for all tex in textures do:

  1. image = context.bindImage(tex, MemoryAccess.WRITE_ONLY)
  2. image.acquireImageForSharingNoEvent
  3. kernel.run1NoEvent
  4. image.releaseImageForSharingNoEvent

Do I need to un-bind the image or dispose the image after releaseImageForSharingNoEvent()?

Because if I use too many textures I get CL_OUT_OF_RESOURCES error in Context.bindImage().

If you haven’t applied the OpenCLObject#register(), then you will need to call OpenCLObject#release() manually to release the native object resources.

AFAIK, LwjglImage#releaseImageForSharingNoEvent() releases the image from the OpenGL linking queue (to free spaces for others queued objects) but not from memory, while LwjglImage#release() calls out for a native object releaser which calls CL10.clReleaseMemObject(mem); and release the object from the memory.