We have moved to a new Sailfish OS Forum. Please start new discussions there.
11

Can be application warmed before lowmemorykiller kills it?

asked 2016-05-05 23:41:24 +0300

Karry gravatar image

updated 2018-12-03 21:52:34 +0300

Tanghus gravatar image

Hi, I am developing map application. It uses in memory cache for map tiles. Bigger cache improves user experience, but my application is first target of lowmemorykiller then. Exist some standard way how application can detect that system under pressure? Application can release majority of its cache in such situation to avoid painful dead.

Only idea that I have is watching /proc/meminfo, but this is not nice solution. I know that kernel developers discussed some mechanism how kernel can notify user space processes that system is in low memory state but no solution was implemented yet. Right?

edit retag flag offensive close delete

Comments

4

Could be lmk says " I'm gonna kill something soon" then when it starts killing app " I'm gona kill you"? Anyway we should have this immediate.

alloj ( 2016-05-06 13:07:32 +0300 )edit
2

WebOS had it on first palm pre with 256MB of ram. It was giving communicates about not enough ram to open another app and suggested to kill some of actually running. Was annoying in the beggining but I got used to it after some time. Also adding swap file helped a bit.

Mądry ( 2016-05-07 08:04:08 +0300 )edit
4

But I don't want to warm user. I want to lowmemorykiller send some signal (SIGUSR1 for example) to _application_. Application should be smart enough to free its resources...

Karry ( 2016-05-07 09:11:10 +0300 )edit

1 Answer

Sort by » oldest newest most voted
14

answered 2016-05-10 09:03:16 +0300

spiiroin gravatar image

While process specific warnings about oom killer activity are not available, MCE daemon is tracking (absolute) system memory pressure via the memnotify kernel interface. Device specific configuration is used to map that in to 3 logical levels ("normal", "warning", "critical" - or "unknown" in case memnotify support / configuration is not present). On warning level non-essential resources should be released, and on critical level oom killing of some processes can be expected.

These logical levels are exposed on D-Bus system bus. The interface is introspectable and can thus be used for example via nemo-qml-plugin-dbus / inspected via qdbus utility:

% /usr/lib/qt5/bin/qdbus --system com.nokia.mce /com/nokia/mce/request|grep memo
method QString com.nokia.mce.request.get_memory_level()
%  /usr/lib/qt5/bin/qdbus --system com.nokia.mce /com/nokia/mce/signal|grep memo
signal void com.nokia.mce.signal.sig_memory_level_ind(QString memory_level)

As an example, the current state can be queried from command line via:

% dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.get_memory_level

And tracked via:

% dbus-monitor --system sender=com.nokia.mce,interface=com.nokia.mce.signal,member=sig_memory_level_ind
edit flag offensive delete publish link more

Comments

6

This belongs in the developer's guide 100% :)

tortoisedoc ( 2016-05-10 10:29:30 +0300 )edit
Login/Signup to Answer

Question tools

Follow
4 followers

Stats

Asked: 2016-05-05 23:41:24 +0300

Seen: 404 times

Last updated: May 10 '16