Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Last active November 6, 2015 10:00
Show Gist options
  • Save qrtt1/d0688d76abb0fcb6eb3c to your computer and use it in GitHub Desktop.
Save qrtt1/d0688d76abb0fcb6eb3c to your computer and use it in GitHub Desktop.
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <string.h>
#include <jni.h>
#include <android/log.h>
#define log(fmt, ...) do{__android_log_print(ANDROID_LOG_INFO, "HELLO-JNI", fmt, ## __VA_ARGS__);}while(0)
/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
*/
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz )
{
const int MB = 1024 * 1024;
int i;
for (i = 1; i < 100000; i++) {
void *mem = malloc(MB);
if (mem != NULL) {
log("alloc %d mb ", i);
} else {
break;
}
}
return (*env)->NewStringUTF(env, "Hello from JNI ! Compiled with ABI " ABI ".");
}
11-06 17:57:28.165 16899-16899/com.example.hellojni I/HELLO-JNI: alloc 1548 mb
11-06 17:57:28.165 16899-16899/com.example.hellojni I/HELLO-JNI: alloc 1549 mb
11-06 17:57:28.165 16899-16899/com.example.hellojni I/HELLO-JNI: alloc 1550 mb
11-06 17:57:28.916 16899-16899/com.example.hellojni D/libEGL: loaded /vendor/lib/egl/libEGL_adreno.so
11-06 17:57:28.946 16899-16899/com.example.hellojni D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
11-06 17:57:28.946 16899-16899/com.example.hellojni E/libEGL: load_driver(/vendor/lib/egl/libGLESv2_adreno.so): dlopen failed: couldn't reserve 1032192 bytes of address space for "/vendor/lib/egl/libGLESv2_adreno.so"
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build: LNXBUILD_AU_LINUX_ANDROID_JB_2.6_RB1.04.03.00.144.009+PATCH[ES]_msm8960_JB_2.6_RB1_CL4169980_release_ENGG (CL4169980)
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: OpenGL ES Shader Compiler Version: 17.01.10.SPL
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: Build Date: 12/17/13 Tue
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: Local Branch:
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: Remote Branch: quic/jb_2.6_rb1.10
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: Local Patches: 579c35762619098d011c9c2a718d817a52a65028 Merge "Merge e6898912278420151291719929e1eb6163c56cc2 on remote branch"
11-06 17:57:28.946 16899-16899/com.example.hellojni I/Adreno-EGL: b075f07ef0d826864515aea57fd03e3d1caed533 Merge e6898912278420151291719929e1eb6163c56cc2 on remote bran
11-06 17:57:28.956 16899-16899/com.example.hellojni W/Adreno-GSL: <os_lib_map:1301>: os_lib_map error: dlopen failed: couldn't reserve 1032192 bytes of address space for "/vendor/lib/egl/libGLESv2_adreno.so", on '/vendor/lib/egl/libGLESv2_adreno.so'
11-06 17:57:28.956 16899-16899/com.example.hellojni E/Adreno-EGL: <egliLoadLibrary:627>: OpenGLES20 lib failed to load
11-06 17:57:28.956 16899-16899/com.example.hellojni E/Adreno-EGL: <eglFetchClientAPIFunctions:3438>: NO OGL 2 functions
11-06 17:57:28.956 16899-16899/com.example.hellojni E/Adreno-EGL: <eglCreateClientApiContext:2206>: Unable to fetch GL functions
11-06 17:57:28.956 16899-16899/com.example.hellojni W/Adreno-EGL: <qeglDrvAPI_eglCreateContext:2399>: EGL_BAD_ALLOC
11-06 17:57:28.956 16899-16899/com.example.hellojni D/AndroidRuntime: Shutting down VM
11-06 17:57:28.956 16899-16899/com.example.hellojni W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41f6f8b0)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: FATAL EXCEPTION: main
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: java.lang.IllegalStateException: Could not create an EGL context. eglCreateContext failed with error: EGL_SUCCESS
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.HardwareRenderer$GlRenderer.createContext(HardwareRenderer.java:1192)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.HardwareRenderer$GlRenderer.initializeEgl(HardwareRenderer.java:1044)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:979)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1546)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1009)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5508)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:562)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:532)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:730)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.os.Looper.loop(Looper.java:213)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5225)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:525)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
11-06 17:57:28.966 16899-16899/com.example.hellojni E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
11-06 17:57:30.808 16899-16908/com.example.hellojni E/dalvikvm: Failed to mmap the JIT code cache: Out of memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment