[PATCH] D42822: [sanitizer] Implement GetRSS on Windows

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 15:01:52 PST 2018


cryptoad created this revision.
cryptoad added reviewers: alekseyshl, rnk.
Herald added subscribers: Sanitizers, delcypher, kubamracek.

Pretty straightforward, returning the `WorkingSetSize` of a
`PROCESS_MEMORY_COUNTERS` structure. AFAIU, `GetProcessMemoryInfo` is in
`kernel32.lib` for Windows 7 and above. Support for earlier Windows versions
would require `psapi.lib`, but I don't think those are supported by ASan?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42822

Files:
  lib/sanitizer_common/sanitizer_win.cc


Index: lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- lib/sanitizer_common/sanitizer_win.cc
+++ lib/sanitizer_common/sanitizer_win.cc
@@ -763,7 +763,10 @@
 }
 
 uptr GetRSS() {
-  return 0;
+  PROCESS_MEMORY_COUNTERS counters;
+  if (!GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)))
+    return 0;
+  return counters.WorkingSetSize;
 }
 
 void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42822.132484.patch
Type: text/x-patch
Size: 504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180201/6b09281c/attachment.bin>


More information about the llvm-commits mailing list