Bug 731 - GLJPanel: Reduce JVM/CPU Heap Memory Usage - Share IntBuffer for readPixel/flip-vert
Summary: GLJPanel: Reduce JVM/CPU Heap Memory Usage - Share IntBuffer for readPixel/fl...
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 2
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2013-05-09 02:16 CEST by Sven Gothel
Modified: 2013-05-09 04:50 CEST (History)
0 users

See Also:
Type: ---
SCM Refs:
ff08ebae2f6ed8788d481f4a21fc7a07a75733ee 66e3917da774b723007811e66d95f37b1ffffc97 e6a234edb1318bb38f6ab65d96518471d0c7fd68 0a7bf77b8c0765f8a53dc72a8edab8e0496938ff ed732cddbcb979062c56e9c93534a232aaa7fa20 890dabf77593732bd9833350b441a37c60f74d45
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2013-05-09 02:16:33 CEST
GLJPanel allocates one or two array backed IntBuffer for each instance.

- 1: BuffereImage
- 1: Vertical Flipping if GLSL flipping is n/a

Extensive use leads to to out of memory errors on the CPU/JVM side.
Comment 1 Sven Gothel 2013-05-09 02:21:34 CEST
Solved by attempting to use a singleton pixel buffer.

Impl. now reuses generalized GLPixelBuffer* -> SingleAWTGLPixelBufferProvider,
incl. row-length-stride where available (GL2GL3).

Further beneficial is the generalized [AWT]GLPixelBuffer* refactored util class,
allowing users to inject a pixel-buffer provider into a toolchain, here:
  - GLJPanel
  - GLReadBufferUtil

New test case: TestGearsES2GLJPanelsAWT
  
GLJPanel SingleAWTGLPixelBufferProvider's screenshots:
     <http://jogamp.org/files/screenshots/gljpanels-singlebuffer/>
Comment 2 Sven Gothel 2013-05-09 02:53:50 CEST
GLJPanel still uses an individual GLPixelBuffer instance.
If using SingleAWTGLPixelBufferProvider, the following creation sequence may happen:
  1- 200x200 *new*
  2- 400x400 *new*
  3- 200x200 *reuse*

the smaller prev. GLPixelBuffer are still in use, even though they could be dropped
in favor of the current biggest GLPixelBuffer.

Hence we have to validate, whether we can make the field static:
  AWTGLPixelBuffer pixelBuffer

this would allow us to get rid of the prev. smaller allocations and save resources.
Comment 3 Sven Gothel 2013-05-09 04:50:09 CEST
fixed, see 890dabf77593732bd9833350b441a37c60f74d45