From 9469825f4f7b98d6afe818043c9fa6b128b0dda3 Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Mon, 28 Feb 2022 13:58:15 +0000
Subject: [PATCH] Collect some more memory stats for help with debugging OOM
 errors.

---
 .../briar/android/reporting/BriarReportCollector.java      | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java b/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java
index 5befcea98e..b6ea21664b 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/reporting/BriarReportCollector.java
@@ -19,6 +19,7 @@ import android.net.NetworkInfo;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.Build;
+import android.os.Debug;
 import android.os.Environment;
 
 import org.briarproject.bramble.api.Pair;
@@ -163,12 +164,16 @@ class BriarReportCollector {
 		memInfo.add("SystemMemoryTotal", mem.totalMem);
 		memInfo.add("SystemMemoryFree", mem.availMem);
 		memInfo.add("SystemMemoryThreshold", mem.threshold);
+		memInfo.add("SystemMemoryLow", mem.lowMemory);
 
 		// Virtual machine memory
 		Runtime runtime = Runtime.getRuntime();
-		memInfo.add("VirtualMachineMemoryAllocated", runtime.totalMemory());
+		memInfo.add("VirtualMachineMemoryTotal", runtime.totalMemory());
 		memInfo.add("VirtualMachineMemoryFree", runtime.freeMemory());
 		memInfo.add("VirtualMachineMemoryMaximum", runtime.maxMemory());
+		memInfo.add("NativeHeapTotal", Debug.getNativeHeapSize());
+		memInfo.add("NativeHeapAllocated", Debug.getNativeHeapAllocatedSize());
+		memInfo.add("NativeHeapFree", Debug.getNativeHeapFreeSize());
 
 		return new ReportItem("Memory", R.string.dev_report_memory, memInfo);
 	}
-- 
GitLab