Modified: trunk/Source/WebKit2/ChangeLog (208537 => 208538)
--- trunk/Source/WebKit2/ChangeLog 2016-11-10 15:43:53 UTC (rev 208537)
+++ trunk/Source/WebKit2/ChangeLog 2016-11-10 16:03:51 UTC (rev 208538)
@@ -1,3 +1,18 @@
+2016-11-10 Carlos Garcia Campos <[email protected]>
+
+ [Linux] Memory process values shown by the WebMemorySampler in linux are wrong
+ https://bugs.webkit.org/show_bug.cgi?id=164591
+
+ Reviewed by Michael Catanzaro.
+
+ It's parsing /proc/self/statm, and returning the values as if they were bytes, but they are number of pages, so
+ to get the bytes we need to take the page size into account. In r208534 I added a method to get /proc/self/statm
+ values in bytes to Platform layer, so we can simply use that instead.
+
+ * Shared/linux/WebMemorySamplerLinux.cpp:
+ (WebKit::WebMemorySampler::sampleWebKit): Use currentProcessMemoryStatus() and update the descriptions to
+ clarify that values are in bytes.
+
2016-10-14 Carlos Garcia Campos <[email protected]>
MemoryPressureHandler shouldn't know how to release WebCore memory
Modified: trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp (208537 => 208538)
--- trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp 2016-11-10 15:43:53 UTC (rev 208537)
+++ trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp 2016-11-10 16:03:51 UTC (rev 208538)
@@ -28,10 +28,11 @@
#if ENABLE(MEMORY_SAMPLER)
-#include "NotImplemented.h"
#include <_javascript_Core/MemoryStatistics.h>
+#include <WebCore/CurrentProcessMemoryStatus.h>
+#include <WebCore/JSDOMWindow.h>
+#include <WebCore/NotImplemented.h>
#include <runtime/JSCInlines.h>
-#include <WebCore/JSDOMWindow.h>
#include <runtime/JSLock.h>
#include <string.h>
#include <sys/sysinfo.h>
@@ -44,16 +45,6 @@
namespace WebKit {
-struct ApplicationMemoryStats {
- size_t totalProgramSize;
- size_t residentSetSize;
- size_t sharedSize;
- size_t textSize;
- size_t librarySize;
- size_t dataStackSize;
- size_t dirtyPageSize;
-};
-
static const unsigned int maxBuffer = 128;
static const unsigned int maxProcessPath = 35;
@@ -84,28 +75,6 @@
stats.values.append(value);
}
-static ApplicationMemoryStats sampleMemoryAllocatedForApplication()
-{
- ApplicationMemoryStats applicationStats = {0, 0, 0, 0, 0, 0, 0};
- char processPath[maxProcessPath];
- snprintf(processPath, maxProcessPath, "/proc/self/statm");
- FILE* statmFileDescriptor = fopen(processPath, "r");
- if (!statmFileDescriptor)
- return applicationStats;
-
- applicationStats.totalProgramSize = nextToken(statmFileDescriptor).toInt();
- applicationStats.residentSetSize = nextToken(statmFileDescriptor).toInt();
- applicationStats.sharedSize = nextToken(statmFileDescriptor).toInt();
- applicationStats.textSize = nextToken(statmFileDescriptor).toInt();
- applicationStats.librarySize = nextToken(statmFileDescriptor).toInt();
- applicationStats.dataStackSize = nextToken(statmFileDescriptor).toInt();
- applicationStats.dirtyPageSize = nextToken(statmFileDescriptor).toInt();
-
- fclose(statmFileDescriptor);
-
- return applicationStats;
-}
-
String WebMemorySampler::processName() const
{
char processPath[maxProcessPath];
@@ -130,15 +99,16 @@
appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Timestamp"), now);
- ApplicationMemoryStats applicationStats = sampleMemoryAllocatedForApplication();
+ ProcessMemoryStatus processMemoryStatus;
+ currentProcessMemoryStatus(processMemoryStatus);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Program Size"), applicationStats.totalProgramSize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("RSS"), applicationStats.residentSetSize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Shared"), applicationStats.sharedSize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Text"), applicationStats.textSize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Library"), applicationStats.librarySize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Data/Stack"), applicationStats.dataStackSize);
- appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Dirty"), applicationStats.dirtyPageSize);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Program Bytes"), processMemoryStatus.size);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Set Bytes"), processMemoryStatus.resident);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Shared Bytes"), processMemoryStatus.shared);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Text Bytes"), processMemoryStatus.text);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Library Bytes"), processMemoryStatus.lib);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Data + Stack Bytes"), processMemoryStatus.data);
+ appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Dirty Bytes"), processMemoryStatus.dt);
size_t totalBytesInUse = 0;
size_t totalBytesCommitted = 0;