pmaports/main/qt5-qtwebengine/patches-musl/renderthread-mallinfo.patch

65 lines
1.9 KiB
Diff
Raw Normal View History

diff --git a/src/3rdparty/chromium/content/renderer/render_thread_impl.cc b/src/3rdparty/chromium/content/renderer/render_thread_impl.cc
index 2934f94..05fee20 100644
--- a/src/3rdparty/chromium/content/renderer/render_thread_impl.cc
+++ b/src/3rdparty/chromium/content/renderer/render_thread_impl.cc
@@ -1821,6 +1821,50 @@ static size_t GetMallocUsage() {
return stats.size_in_use;
}
+} // namespace
+
+#elif defined(OS_LINUX) && !defined(__GLIBC__)
+namespace {
+
+static size_t GetMallocUsage() {
+ char *line=NULL;
+ size_t n,usage=0;
+ FILE *f = fopen("/proc/self/maps", "r");
+ char *path, *perm;
+ if (f == NULL) {
+ perror("/proc/self/maps");
+ return 0;
+ }
+ path = (char *)malloc(PATH_MAX+16);
+ if (path == NULL)
+ goto out;
+ perm = path + PATH_MAX;
+
+ while (getline(&line, &n, f) >=0) {
+ size_t start,end,offset,inode;
+ int devmaj, devmin, items;
+
+ items = sscanf(line, "%zx-%zx %s %zx %x:%x %zu %s",
+ &start, &end, perm, &offset,
+ &devmaj, &devmin, &inode, path);
+
+ if (items < 7)
+ continue;
+
+ if (items < 8)
+ path[0] = '\0';
+
+ if ((strcmp(perm, "rw-p") == 0 && devmaj+devmin == 0)
+ && (path[0] == '\0' || strcmp(path, "[heap]") == 0))
+ usage += end-start;
+ }
+ free(line);
+ free(path);
+out:
+ fclose(f);
+ return usage;
+}
+
} // namespace
#endif
@@ -1840,7 +1884,7 @@ void RenderThreadImpl::RecordPurgeAndSuspendMetrics() const {
blink_stats.partitionAllocTotalAllocatedBytes / 1024);
UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.BlinkGCKB",
blink_stats.blinkGCTotalAllocatedBytes / 1024);
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_ANDROID)
struct mallinfo minfo = mallinfo();
#if defined(USE_TCMALLOC)
size_t malloc_usage = minfo.uordblks;