Skip to content

Commit b32bde1

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm] Label virtual memory allocations on Android.
TEST=examine /proc/pid/smaps and Observatory's "process memory" page Change-Id: I03922c9c604ceef8901a8946481d0ccc31110b72 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213289 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent d787e78 commit b32bde1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

runtime/vm/service.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4283,10 +4283,17 @@ static void AddVMMappings(JSONArray* rss_children) {
42834283
// Skipping a few paths to avoid double counting:
42844284
// (deleted) - memfd dual mapping in Dart heap
42854285
// [heap] - sbrk area, should already included with malloc
4286-
// <empty> - anonymous mappings, mostly in Dart heap
4286+
// <empty> - anonymous mappings, mostly in Dart heap (Linux)
4287+
// [anon:dart-*] - as labelled (Android)
42874288
if ((strcmp(property, "Rss:") == 0) && (size != 0) &&
42884289
(strcmp(path, "(deleted)") != 0) && (strcmp(path, "[heap]") != 0) &&
4289-
(strcmp(path, "") != 0)) {
4290+
(strcmp(path, "") != 0) &&
4291+
(strcmp(path, "[anon:dart-newspace]") != 0) &&
4292+
(strcmp(path, "[anon:dart-oldspace]") != 0) &&
4293+
(strcmp(path, "[anon:dart-codespace]") != 0) &&
4294+
(strcmp(path, "[anon:dart-profiler]") != 0) &&
4295+
(strcmp(path, "[anon:dart-timeline]") != 0) &&
4296+
(strcmp(path, "[anon:dart-zone]") != 0)) {
42904297
bool updated = false;
42914298
for (intptr_t i = 0; i < mappings.length(); i++) {
42924299
if (strcmp(mappings[i].path, path) == 0) {

runtime/vm/virtual_memory_posix.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include <sys/syscall.h>
1616
#include <unistd.h>
1717

18+
#if defined(DART_HOST_OS_ANDROID)
19+
#include <sys/prctl.h>
20+
#endif
21+
1822
#include "platform/assert.h"
1923
#include "platform/utils.h"
2024
#include "vm/heap/pages.h"
@@ -433,6 +437,10 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
433437
return nullptr;
434438
}
435439

440+
#if defined(DART_HOST_OS_ANDROID)
441+
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, address, size, name);
442+
#endif
443+
436444
MemoryRegion region(reinterpret_cast<void*>(address), size);
437445
return new VirtualMemory(region, region);
438446
}

0 commit comments

Comments
 (0)