Author Topic: clear data  (Read 9997 times)

Offline jms

  • byte
  • *
  • Posts: 2
    • View Profile
clear data
« on: December 10, 2010, 09:29:25 am »
Hi,
I have a similar problem to post the 12th October "Not Able to clear the data, but can not get me work.

I'm using the libraries in a live wallpaper. If I give a set wallpaper, before it has finished generating the scene and show the preview, then either make an application crash or shows me with malformed elements. For example, a textured Primitives.getPlane, I get only a blank background.

I put the trick mentioned in this post, before this code called by OnDestroy, but does not work:

if(world!=null){
            world.removeAll();
            world.dispose();
            world = null;
}

could someone help me? thanks!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #1 on: December 10, 2010, 10:52:39 am »
I don't see a relation between your problem and the post you are refering to. Can you explain what you do in a little more detail? Apart from that: This workaround isn't needed anymore.

Offline jms

  • byte
  • *
  • Posts: 2
    • View Profile
Re: clear data
« Reply #2 on: December 10, 2010, 11:56:59 am »
Hi,

When you choose the wallpaper to see it, takes a few seconds to display, if before the end I give the button Set wallpaper for my screen, then crash the application.

For the logs I'm seeing, it looks as if it began to remove items before calling internally and to clean onDestoy world. I do not know if there is a way to stop all creation environment before it is finished. I do not know exactly how to explain.

Thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #3 on: December 10, 2010, 10:21:11 pm »
I still don't get it... ???

Offline Kaiidyn

  • long
  • ***
  • Posts: 103
    • View Profile
Re: clear data
« Reply #4 on: December 13, 2010, 10:19:59 pm »
if(object != null){ remove object; } in your cleanup.
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control. - Grady Booch

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #5 on: August 08, 2011, 10:16:33 am »
I have the same problem, second run onCreateEngine() of wallpaper service crash;
Somebody can tell right initialization/destroy sequence?
I try next -
 
Code: [Select]
onCreateEngine()  {
       return = new MyEngine();
}
//in engine
onCreate(){
      executor = Executors.newSingleThreadExecutor();
}
onDestroy(){
  executor.shutdownNow();
  super.onDestroy();
}
onSurfaceCreated(){
      //init gl/egl
                        EGLConfig config = null;
egl = (EGL10) EGLContext.getEGL();
glDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
int[] version = new int[2];
egl.eglInitialize(glDisplay, version);
int[] configSpec = new int[]{EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};// {EGL10.EGL_RED_SIZE, 5, EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
EGLConfig[] configs = new EGLConfig[1];
int[] numConfig = new int[1];
egl.eglChooseConfig(glDisplay, configSpec, configs, 1, numConfig);
config = configs[0];

glc = egl.eglCreateContext(glDisplay, config, EGL10.EGL_NO_CONTEXT, null);
glSurface = egl.eglCreateWindowSurface(glDisplay, config, holder, null);
egl.eglMakeCurrent(glDisplay, glSurface, glSurface, glc);
gl = (GL10) (glc.getGL());
//create renderer
renderer = new MyRenderer();
renderer.onSurfaceCreated(gl, config);
//in renderer.onSurfaceCreated   create word, textures objects etc
}
onSurfaceDestroyed(final SurfaceHolder holder) {
super.onSurfaceDestroyed(holder);
egl.eglMakeCurrent(glDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
egl.eglDestroySurface(glDisplay, glSurface);
egl.eglDestroyContext(glDisplay, glc);
egl.eglTerminate(glDisplay);
mVisible = false;
}
// on surfaceChange & onVisibilityChanged has only logic for call draw command in executor

« Last Edit: August 08, 2011, 10:28:07 am by Alexey »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #6 on: August 08, 2011, 10:48:14 am »
What kind of "crash"?

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #7 on: August 08, 2011, 11:07:58 am »
ERROR/Surface(239): surface (id=0, identity=22) is invalid, err=-19 (No such device)
and black screen wallpaper

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #8 on: August 08, 2011, 11:27:41 am »
What i should destroy from jpct part in  onSurfaceDestroyed() of Engine ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #9 on: August 08, 2011, 12:17:49 pm »
Android destroys the gl context und surfaces itself. The engine contains no code to deal with that and it doesn't have to. What you can do in the engine, is to clean up some memory or maybe unload data from the gpu as long as the context is still valid, but that can't cause nor avoid your problem. Your problem seems to be related somehow to your surface setup code and that's out of the scope of jPCT-AE.

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #10 on: August 08, 2011, 08:56:12 pm »
Now, when i go to preview wallpaper 2nd time, i have java.lang.OutOfMemoryError.
Code: [Select]
08-08 21:42:01.784: INFO/jPCT-AE(22421): OpenGL vendor:     Qualcomm
08-08 21:42:01.784: INFO/jPCT-AE(22421): OpenGL renderer:   Adreno 205
08-08 21:42:01.784: INFO/jPCT-AE(22421): OpenGL version:    OpenGL ES-CM 1.1
08-08 21:42:01.794: INFO/jPCT-AE(22421): OpenGL renderer initialized (using 2 texture stages)
08-08 21:42:01.814: INFO/jPCT-AE(22421): Subobject of object 379/object381 compiled to flat fixed point data using 384 vertices in 3ms!
08-08 21:42:01.814: INFO/jPCT-AE(22421): Object 379/object381 compiled to 1 subobjects in 12ms!
08-08 21:42:01.814: INFO/jPCT-AE(22421): Object 'object381' uses one texture set!
08-08 21:42:01.824: INFO/jPCT-AE(22421): Subobject of object 381/object383 compiled to flat fixed point data using 384 vertices in 4ms!
08-08 21:42:01.824: INFO/jPCT-AE(22421): Object 381/object383 compiled to 1 subobjects in 10ms!
08-08 21:42:01.824: INFO/jPCT-AE(22421): Object 'object383' uses one texture set!
08-08 21:42:01.824: INFO/jPCT-AE(22421): [ 1312828921830 ] - WARNING: Object object385 hasn't been build yet. Forcing build()!
08-08 21:42:01.864: INFO/jPCT-AE(22421): Subobject of object 383/object385 compiled to flat fixed point data using 4110 vertices in 5ms!
08-08 21:42:01.864: INFO/jPCT-AE(22421): Object 383/object385 compiled to 1 subobjects in 35ms!
08-08 21:42:01.864: INFO/jPCT-AE(22421): [ 1312828921866 ] - WARNING: Object object387 hasn't been build yet. Forcing build()!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Subobject of object 385/object387 compiled to flat fixed point data using 3510 vertices in 5ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Object 385/object387 compiled to 1 subobjects in 19ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Subobject of object 387/object389 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Object 387/object389 compiled to 1 subobjects in 3ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Object 'object389' uses one texture set!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Subobject of object 389/object391 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Object 389/object391 compiled to 1 subobjects in 2ms!
08-08 21:42:01.884: INFO/jPCT-AE(22421): Object 'object391' uses one texture set!
08-08 21:42:01.884: INFO/jPCT-AE(22421): [ 1312828921892 ] - WARNING: Object object393 hasn't been build yet. Forcing build()!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Subobject of object 391/object393 compiled to flat fixed point data using 366 vertices in 1ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Object 391/object393 compiled to 1 subobjects in 2ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): [ 1312828921896 ] - WARNING: Object object395 hasn't been build yet. Forcing build()!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Subobject of object 393/object395 compiled to flat fixed point data using 264 vertices in 1ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Object 393/object395 compiled to 1 subobjects in 2ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Subobject of object 395/object397 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Object 395/object397 compiled to 1 subobjects in 2ms!
08-08 21:42:01.894: INFO/jPCT-AE(22421): Object 'object397' uses one texture set!
08-08 21:42:01.904: INFO/jPCT-AE(22421): Subobject of object 397/object399 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.904: INFO/jPCT-AE(22421): Object 397/object399 compiled to 1 subobjects in 4ms!
08-08 21:42:01.904: INFO/jPCT-AE(22421): Object 'object399' uses one texture set!
08-08 21:42:01.904: INFO/jPCT-AE(22421): [ 1312828921907 ] - WARNING: Object object401 hasn't been build yet. Forcing build()!
08-08 21:42:01.924: INFO/jPCT-AE(22421): Subobject of object 399/object401 compiled to flat fixed point data using 4110 vertices in 5ms!
08-08 21:42:01.924: INFO/jPCT-AE(22421): Object 399/object401 compiled to 1 subobjects in 21ms!
08-08 21:42:01.924: INFO/jPCT-AE(22421): [ 1312828921928 ] - WARNING: Object object403 hasn't been build yet. Forcing build()!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Subobject of object 401/object403 compiled to flat fixed point data using 3510 vertices in 5ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Object 401/object403 compiled to 1 subobjects in 19ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Subobject of object 403/object405 compiled to flat fixed point data using 384 vertices in 2ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Object 403/object405 compiled to 1 subobjects in 3ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Object 'object405' uses one texture set!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Subobject of object 405/object407 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Object 405/object407 compiled to 1 subobjects in 3ms!
08-08 21:42:01.944: INFO/jPCT-AE(22421): Object 'object407' uses one texture set!
08-08 21:42:01.944: INFO/jPCT-AE(22421): [ 1312828921954 ] - WARNING: Object object409 hasn't been build yet. Forcing build()!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Subobject of object 407/object409 compiled to flat fixed point data using 366 vertices in 1ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Object 407/object409 compiled to 1 subobjects in 2ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): [ 1312828921957 ] - WARNING: Object object411 hasn't been build yet. Forcing build()!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Subobject of object 409/object411 compiled to flat fixed point data using 264 vertices in 0ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Object 409/object411 compiled to 1 subobjects in 2ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Subobject of object 411/object413 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Object 411/object413 compiled to 1 subobjects in 2ms!
08-08 21:42:01.954: INFO/jPCT-AE(22421): Object 'object413' uses one texture set!
08-08 21:42:01.964: INFO/jPCT-AE(22421): Subobject of object 413/object415 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:01.964: INFO/jPCT-AE(22421): Object 413/object415 compiled to 1 subobjects in 3ms!
08-08 21:42:01.964: INFO/jPCT-AE(22421): Object 'object415' uses one texture set!
08-08 21:42:01.964: INFO/jPCT-AE(22421): [ 1312828921966 ] - WARNING: Object object417 hasn't been build yet. Forcing build()!
08-08 21:42:01.984: INFO/jPCT-AE(22421): Subobject of object 415/object417 compiled to flat fixed point data using 4110 vertices in 6ms!
08-08 21:42:01.984: INFO/jPCT-AE(22421): Object 415/object417 compiled to 1 subobjects in 20ms!
08-08 21:42:01.984: INFO/jPCT-AE(22421): [ 1312828921987 ] - WARNING: Object object419 hasn't been build yet. Forcing build()!
08-08 21:42:01.994: INFO/jPCT-AE(22421): Subobject of object 417/object419 compiled to flat fixed point data using 3510 vertices in 4ms!
08-08 21:42:01.994: INFO/jPCT-AE(22421): Object 417/object419 compiled to 1 subobjects in 14ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Subobject of object 419/object421 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Object 419/object421 compiled to 1 subobjects in 5ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Object 'object421' uses one texture set!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Subobject of object 421/object423 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Object 421/object423 compiled to 1 subobjects in 2ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Object 'object423' uses one texture set!
08-08 21:42:02.004: INFO/jPCT-AE(22421): [ 1312828922010 ] - WARNING: Object object425 hasn't been build yet. Forcing build()!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Subobject of object 423/object425 compiled to flat fixed point data using 366 vertices in 1ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): Object 423/object425 compiled to 1 subobjects in 3ms!
08-08 21:42:02.004: INFO/jPCT-AE(22421): [ 1312828922013 ] - WARNING: Object object427 hasn't been build yet. Forcing build()!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Subobject of object 425/object427 compiled to flat fixed point data using 264 vertices in 2ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Object 425/object427 compiled to 1 subobjects in 4ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Subobject of object 427/object429 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Object 427/object429 compiled to 1 subobjects in 3ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Object 'object429' uses one texture set!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Subobject of object 429/object431 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Object 429/object431 compiled to 1 subobjects in 2ms!
08-08 21:42:02.014: INFO/jPCT-AE(22421): Object 'object431' uses one texture set!
08-08 21:42:02.014: INFO/jPCT-AE(22421): [ 1312828922024 ] - WARNING: Object object433 hasn't been build yet. Forcing build()!
08-08 21:42:02.034: INFO/jPCT-AE(22421): Subobject of object 431/object433 compiled to flat fixed point data using 4110 vertices in 6ms!
08-08 21:42:02.034: INFO/jPCT-AE(22421): Object 431/object433 compiled to 1 subobjects in 19ms!
08-08 21:42:02.034: INFO/jPCT-AE(22421): [ 1312828922044 ] - WARNING: Object object435 hasn't been build yet. Forcing build()!
08-08 21:42:02.054: INFO/jPCT-AE(22421): Subobject of object 433/object435 compiled to flat fixed point data using 3510 vertices in 4ms!
08-08 21:42:02.054: INFO/jPCT-AE(22421): Object 433/object435 compiled to 1 subobjects in 17ms!
08-08 21:42:02.054: INFO/jPCT-AE(22421): Subobject of object 435/object437 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.054: INFO/jPCT-AE(22421): Object 435/object437 compiled to 1 subobjects in 2ms!
08-08 21:42:02.054: INFO/jPCT-AE(22421): Object 'object437' uses one texture set!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Subobject of object 437/object439 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Object 437/object439 compiled to 1 subobjects in 3ms!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Object 'object439' uses one texture set!
08-08 21:42:02.064: INFO/jPCT-AE(22421): [ 1312828922068 ] - WARNING: Object object441 hasn't been build yet. Forcing build()!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Subobject of object 439/object441 compiled to flat fixed point data using 366 vertices in 1ms!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Object 439/object441 compiled to 1 subobjects in 3ms!
08-08 21:42:02.064: INFO/jPCT-AE(22421): [ 1312828922072 ] - WARNING: Object object443 hasn't been build yet. Forcing build()!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Subobject of object 441/object443 compiled to flat fixed point data using 264 vertices in 1ms!
08-08 21:42:02.064: INFO/jPCT-AE(22421): Object 441/object443 compiled to 1 subobjects in 2ms!
08-08 21:42:02.074: INFO/jPCT-AE(22421): Subobject of object 443/object445 compiled to flat fixed point data using 384 vertices in 1ms!
08-08 21:42:02.074: INFO/jPCT-AE(22421): Object 443/object445 compiled to 1 subobjects in 3ms!
08-08 21:42:02.074: INFO/jPCT-AE(22421): Object 'object445' uses one texture set!
08-08 21:42:02.074: ERROR/dalvikvm-heap(22421): 4608-byte external allocation too large for this process.
08-08 21:42:02.074: ERROR/dalvikvm(22421): Out of memory: Heap Size=16859KB, Allocated=16593KB, Bitmap Size=8491KB, Limit=21884KB
08-08 21:42:02.074: ERROR/dalvikvm(22421): Trim info: Footprint=16967KB, Allowed Footprint=17095KB, Trimmed=1248KB
08-08 21:42:02.074: WARN/OSMemory(22421): External allocation of 4608 bytes was rejected
08-08 21:42:02.084: WARN/dalvikvm(22421): threadid=9: thread exiting with uncaught exception (group=0x40025a70)
08-08 21:42:02.094: ERROR/AndroidRuntime(22421): FATAL EXCEPTION: GLThread 12
        java.lang.OutOfMemoryError
        at org.apache.harmony.luni.platform.OSMemory.malloc(Native Method)
        at org.apache.harmony.luni.platform.PlatformAddressFactory.alloc(PlatformAddressFactory.java:150)
        at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:66)
        at java.nio.ReadWriteDirectByteBuffer.<init>(ReadWriteDirectByteBuffer.java:51)
        at java.nio.BufferFactory.newDirectByteBuffer(BufferFactory.java:93)
        at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:68)
        at com.threed.jpct.CompiledInstance.fill(CompiledInstance.java:704)
        at com.threed.jpct.Object3DCompiler.compile(Object3DCompiler.java:136)
        at com.threed.jpct.World.compile(World.java:2051)
        at com.threed.jpct.World.renderScene(World.java:1093)
        at com.ua.cv.abel.dna.wallpaper.DnaRenderer.onDrawFrame(MyRenderer.java:272)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #11 on: August 08, 2011, 09:14:29 pm »
Is this code:

Code: [Select]
if(world!=null){
            world.removeAll();
            world.dispose();
            world = null;
}

still in place and called?

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #12 on: August 08, 2011, 09:29:10 pm »
this method now used for clearing. I refactor some in object building (use clone) and now on 4th running  memory out, so objects dont removing
Code: [Select]
public void release() {
System.out.println("Clear renderer");
if (world != null) {
world.dispose();
world = null;
}
if (fb != null) {
fb.dispose();
fb = null;
}
}

Offline Alexey

  • int
  • **
  • Posts: 50
    • View Profile
Re: clear data
« Reply #13 on: August 08, 2011, 09:33:11 pm »
aaaaaaaaaaaaaaaaaaaaaaa, i forgot world.removeAll(); :)  , trying with it

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: clear data
« Reply #14 on: August 08, 2011, 09:34:35 pm »
I was about to suggest this... ;)