diff options
| author | Po Lu | 2023-11-10 14:57:24 +0800 |
|---|---|---|
| committer | Po Lu | 2023-11-10 14:58:16 +0800 |
| commit | 5324723c2bcab7062f393a5057e51733a1715788 (patch) | |
| tree | 104b3deb89473a59a2cbdb29f6b63e97fd0f3d7d /java | |
| parent | 5dc3c9f4eca2e3c4b4059cc5b52b56c98eb3d961 (diff) | |
| download | emacs-5324723c2bcab7062f393a5057e51733a1715788.tar.gz emacs-5324723c2bcab7062f393a5057e51733a1715788.zip | |
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.java | 3 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 12 |
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 | |||
| 96 | thread, then return. */ | 96 | thread, then return. */ |
| 97 | public static native void shutDownEmacs (); | 97 | public static native void shutDownEmacs (); |
| 98 | 98 | ||
| 99 | /* Garbage collect and clear each frame's image cache. */ | ||
| 100 | public static native void onLowMemory (); | ||
| 101 | |||
| 99 | /* Abort and generate a native core dump. */ | 102 | /* Abort and generate a native core dump. */ |
| 100 | public static native void emacsAbort (); | 103 | public static native void emacsAbort (); |
| 101 | 104 | ||
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 | |||
| 321 | } | 321 | } |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | /* The native functions the subsequent two functions call do nothing | ||
| 325 | in the infrequent case the Emacs thread is awaiting a response | ||
| 326 | for the main thread. Caveat emptor! */ | ||
| 327 | |||
| 324 | @Override | 328 | @Override |
| 325 | public void | 329 | public void |
| 326 | onDestroy () | 330 | onDestroy () |
| @@ -333,6 +337,14 @@ public final class EmacsService extends Service | |||
| 333 | super.onDestroy (); | 337 | super.onDestroy (); |
| 334 | } | 338 | } |
| 335 | 339 | ||
| 340 | @Override | ||
| 341 | public void | ||
| 342 | onLowMemory () | ||
| 343 | { | ||
| 344 | EmacsNative.onLowMemory (); | ||
| 345 | super.onLowMemory (); | ||
| 346 | } | ||
| 347 | |||
| 336 | 348 | ||
| 337 | 349 | ||
| 338 | /* Functions from here on must only be called from the Emacs | 350 | /* Functions from here on must only be called from the Emacs |