From a121055f9e4ac039fa820f06e9e81e5ce72e5e24 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Mar 2013 17:36:12 +0100 Subject: NEWTGearsES2Activity*: Adding property to enable 'process kill' behavior (memory and killSelf) --- .../opengl/test/android/NEWTGearsES2Activity.java | 34 ++++++++++++++++++++++ .../test/android/NEWTGearsES2ActivityLauncher.java | 4 ++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index e45df5eae..542912c08 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -27,6 +27,10 @@ */ package com.jogamp.opengl.test.android; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.ArrayList; + import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -49,6 +53,7 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { static final String forceRGBA5650 = "demo.force.rgba5650"; static final String forceECT = "demo.force.ect"; + static final String forceKillProcessTest = "demo.force.killProcessTest"; @Override public void onCreate(Bundle savedInstanceState) { @@ -76,6 +81,35 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { System.err.println("ScreenMode Changed: "+sm); } }); + if( null != System.getProperty(forceKillProcessTest) ) { + Log.d(TAG, "forceKillProcessTest"); + glWindow.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if( e.getPointerCount() == 3 ) { + Log.d(TAG, "MemoryHog"); + new Thread(new Runnable() { + public void run() { + ArrayList buffers = new ArrayList(); + while(true) { + final int halfMB = 512 * 1024; + final float osizeMB = buffers.size() * 0.5f; + final float nsizeMB = osizeMB + 0.5f; + System.err.println("MemoryHog: ****** +4k: "+osizeMB+" MB +"+nsizeMB+" MB - Try"); + buffers.add(ByteBuffer.allocateDirect(halfMB)); // 0.5 MB each + System.err.println("MemoryHog: ****** +4k: "+osizeMB+" MB +"+nsizeMB+" MB - Done"); + try { + Thread.sleep(500); + } catch (Exception e) {}; + } + } }, "MemoryHog").start(); + } else if( e.getPointerCount() == 4 ) { + Log.d(TAG, "ForceKill"); + android.os.Process.killProcess( android.os.Process.myPid() ); + } + } + }); + } Animator animator = new Animator(glWindow); // animator.setRunAsFastAsPossible(true); // glWindow.setSkipContextReleaseThread(animator.getThread()); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index af5b70776..5e7a5c489 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -60,7 +60,9 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc props.setProperty("newt.debug.Window", "true"); props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); - // props.setProperty("newt.debug.Android.MouseEvent", "true"); + // props.setProperty("newt.debug.Android.MouseEvent", "true"); + + // props.setProperty("demo.force.killProcessTest", "true"); } @Override -- cgit v1.2.3