Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Unified Diff: src/platform-linux.cc

Issue 10961042: Implement committed physical memory stats for Linux. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index 606d10236eb5f6a498eda7034b609edd56974d7a..f934da1c751c820cae5f4208f664cba6ae9058e5 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -701,6 +701,24 @@ bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
}
+bool VirtualMemory::CommittedPhysicalSizeInRegion(
+ void* base, size_t size, size_t* physical) {
+ const size_t page_size = sysconf(_SC_PAGESIZE);
+ base = reinterpret_cast<void*>(
+ reinterpret_cast<intptr_t>(base) & ~(page_size - 1));
+ const size_t pages = (size + page_size - 1) / page_size;
+ ScopedVector<unsigned char> buffer(pages);
+ int result = mincore(base, size, buffer.start());
+ if (result) return false;
+ int resident_pages = 0;
+ for (unsigned i = 0; i < pages; ++i) {
+ resident_pages += buffer[i] & 1;
+ }
+ *physical = resident_pages * page_size;
+ return true;
+}
+
+
class Thread::PlatformData : public Malloced {
public:
PlatformData() : thread_(kNoThread) {}
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698