summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-11-10 14:57:24 +0800
committerPo Lu <luangruo@yahoo.com>2023-11-10 14:58:16 +0800
commit5324723c2bcab7062f393a5057e51733a1715788 (patch)
tree104b3deb89473a59a2cbdb29f6b63e97fd0f3d7d /java
parent5dc3c9f4eca2e3c4b4059cc5b52b56c98eb3d961 (diff)
downloademacs-5324723c2bcab7062f393a5057e51733a1715788.tar.gz
Clear image caches in reaction to system VM warnings
* java/org/gnu/emacs/EmacsNative.java (onLowMemory): * java/org/gnu/emacs/EmacsService.java (onLowMemory): New function. * src/android.c (android_on_low_memory, onLowMemory): New functions called when a VM caution is registered. Clear the image cache and run garbage collection.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java3
-rw-r--r--java/org/gnu/emacs/EmacsService.java12
2 files changed, 15 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 946a38f7f84..78176dd0e47 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -96,6 +96,9 @@ public final class EmacsNative
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 ();
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index ab6d57b9c4f..1aac1a6c4dd 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -321,6 +321,10 @@ public final class EmacsService extends Service
}
}
+ /* 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 ()
@@ -333,6 +337,14 @@ public final class EmacsService extends Service
super.onDestroy ();
}
+ @Override
+ public void
+ onLowMemory ()
+ {
+ EmacsNative.onLowMemory ();
+ super.onLowMemory ();
+ }
+
/* Functions from here on must only be called from the Emacs