美文网首页Android高阶
android go 内存回收

android go 内存回收

作者: 布吉刀 | 来源:发表于2018-12-10 18:01 被阅读1次

内核通过/dev/memcg/memory.pressure_level来更新。
具体patch见
memcg: Add memory.pressure_level events

+static bool vmpressure_event(struct vmpressure *vmpr,
+                unsigned long scanned, unsigned long reclaimed)
+{
+   struct vmpressure_event *ev;
+   int level = vmpressure_calc_level(scanned, reclaimed);
+   bool signalled = false;
+
+   mutex_lock(&vmpr->events_lock);
+
+   list_for_each_entry(ev, &vmpr->events, node) {
+       if (level >= ev->level) {
+           eventfd_signal(ev->efd, 1);
+           signalled = true;
+       }
+   }
+
+   mutex_unlock(&vmpr->events_lock);
+
+   return signalled;
+}

新的计算方式为
Pressure=memory.usage_in_bytes*100/memory.memsw.usage_in_bytes
细节见Lmkd pressure值计算(Android lmkd计算核心)

相关文章

网友评论

    本文标题:android go 内存回收

    本文链接:https://www.haomeiwen.com/subject/aiedhqtx.html