thread, then return. */
public static native void shutDownEmacs ();
+ /* Garbage collect and clear each frame's image cache. */
+ public static native void onLowMemory ();
+
/* Abort and generate a native core dump. */
public static native void emacsAbort ();
}
}
+ /* The native functions the subsequent two functions call do nothing
+ in the infrequent case the Emacs thread is awaiting a response
+ for the main thread. Caveat emptor! */
+
@Override
public void
onDestroy ()
super.onDestroy ();
}
+ @Override
+ public void
+ onLowMemory ()
+ {
+ EmacsNative.onLowMemory ();
+ super.onLowMemory ();
+ }
+
\f
/* Functions from here on must only be called from the Emacs
android_run_in_emacs_thread (android_shut_down_emacs, NULL);
}
+/* Carry out garbage collection and clear all image caches on the
+ Android terminal. Called when the system has depleted most of its
+ memory and desires that background processes release unused
+ core. */
+
+static void
+android_on_low_memory (void *closure)
+{
+ Fclear_image_cache (Qt, Qt);
+ garbage_collect ();
+}
+
+JNIEXPORT void JNICALL
+NATIVE_NAME (onLowMemory) (JNIEnv *env, jobject object)
+{
+ JNI_STACK_ALIGNMENT_PROLOGUE;
+
+ android_run_in_emacs_thread (android_on_low_memory, NULL);
+}
+
JNIEXPORT jlong JNICALL
NATIVE_NAME (sendConfigureNotify) (JNIEnv *env, jobject object,
jshort window, jlong time,