Modified: trunk/Source/WebKit/blackberry/ChangeLog (125082 => 125083)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-08-08 20:49:44 UTC (rev 125082)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-08-08 21:02:15 UTC (rev 125083)
@@ -1,3 +1,41 @@
+2012-08-08 Jacky Jiang <zhaji...@rim.com>
+
+ [BlackBerry] Implement about:memory-live
+ https://bugs.webkit.org/show_bug.cgi?id=93153
+
+ Reviewed by Yong Li.
+ Patch by Jacky Jiang <zhaji...@rim.com>
+
+ Implementing about:memory-live to track memory peaks:
+ - about:memory-live/start: start tracking memory peaks.
+ - about:memory-live: show memory peaks every 30ms.
+ - about:memory-live/stop: stop tracking and show memory peaks.
+
+ Mainly track the following memory peaks:
+ - Total used memory (malloc + JSC).
+ - Total committed memory.
+ - Total mapped memory.
+
+ Add total committed memory for about:memory
+
+ * WebKitSupport/AboutData.cpp:
+ (BlackBerry::WebKit::memoryPage):
+ (WebKit):
+ (MemoryTracker):
+ (BlackBerry::WebKit::MemoryTracker::isActive):
+ (BlackBerry::WebKit::MemoryTracker::clear):
+ (BlackBerry::WebKit::MemoryTracker::peakTotalUsedMemory):
+ (BlackBerry::WebKit::MemoryTracker::peakTotalCommittedMemory):
+ (BlackBerry::WebKit::MemoryTracker::peakTotalMappedMemory):
+ (BlackBerry::WebKit::MemoryTracker::MemoryTracker):
+ (BlackBerry::WebKit::MemoryTracker::instance):
+ (BlackBerry::WebKit::MemoryTracker::start):
+ (BlackBerry::WebKit::MemoryTracker::stop):
+ (BlackBerry::WebKit::MemoryTracker::updateMemoryPeaks):
+ (BlackBerry::WebKit::memoryPeaksToHtmlTable):
+ (BlackBerry::WebKit::memoryLivePage):
+ (BlackBerry::WebKit::aboutData):
+
2012-08-08 Antonio Gomes <ago...@rim.com>
[BlackBerry] Tie up the scrolling machinery to the graphics tree when applicable for in-region scroll
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp (125082 => 125083)
--- trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp 2012-08-08 20:49:44 UTC (rev 125082)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/AboutData.cpp 2012-08-08 21:02:15 UTC (rev 125083)
@@ -255,8 +255,10 @@
page += "<div class='box'><div class='box-title'>Process memory usage summary</div><table class='fixed-table'><col width=75%><col width=25%>";
- page += numberToHTMLTr("Total memory usage (malloc + JSC)", mallocInfo.usmblks + mallocInfo.uordblks + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity());
+ page += numberToHTMLTr("Total used memory (malloc + JSC)", mallocInfo.usmblks + mallocInfo.uordblks + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity());
+ page += numberToHTMLTr("Total committed memory", BlackBerry::Platform::totalCommittedMemory());
+
struct stat processInfo;
if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo))
page += numberToHTMLTr("Total mapped memory", processInfo.st_size);
@@ -307,6 +309,125 @@
return page;
}
+#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
+class MemoryTracker {
+public:
+ static MemoryTracker& instance();
+ void start();
+ void stop();
+ bool isActive() const { return m_memoryTrackingTimer.isActive(); }
+ void clear() { m_peakTotalUsedMemory = 0; m_peakTotalCommittedMemory = 0; m_peakTotalMappedMemory = 0; }
+ void updateMemoryPeaks(Timer<MemoryTracker>*);
+ unsigned peakTotalUsedMemory() const { return m_peakTotalUsedMemory; }
+ unsigned peakTotalCommittedMemory() const {return m_peakTotalCommittedMemory; }
+ unsigned peakTotalMappedMemory() const { return m_peakTotalMappedMemory; }
+
+private:
+ MemoryTracker();
+ Timer<MemoryTracker> m_memoryTrackingTimer;
+ unsigned m_peakTotalUsedMemory;
+ unsigned m_peakTotalCommittedMemory;
+ unsigned m_peakTotalMappedMemory;
+};
+
+MemoryTracker::MemoryTracker()
+ : m_memoryTrackingTimer(this, &MemoryTracker::updateMemoryPeaks)
+ , m_peakTotalUsedMemory(0)
+ , m_peakTotalCommittedMemory(0)
+ , m_peakTotalMappedMemory(0)
+{
+}
+
+MemoryTracker& MemoryTracker::instance()
+{
+ DEFINE_STATIC_LOCAL(MemoryTracker, s_memoryTracker, ());
+ return s_memoryTracker;
+}
+
+void MemoryTracker::start()
+{
+ clear();
+ if (!m_memoryTrackingTimer.isActive())
+ m_memoryTrackingTimer.start(0, 0.01);
+}
+
+void MemoryTracker::stop()
+{
+ m_memoryTrackingTimer.stop();
+}
+
+void MemoryTracker::updateMemoryPeaks(Timer<MemoryTracker>*)
+{
+ // JS engine memory usage.
+ JSC::GlobalMemoryStatistics jscMemoryStat = JSC::globalMemoryStatistics();
+ JSC::Heap& mainHeap = JSDOMWindow::commonJSGlobalData()->heap;
+
+ // Malloc info.
+ struct mallinfo mallocInfo = mallinfo();
+
+ // Malloc and JSC memory.
+ unsigned totalUsedMemory = static_cast<unsigned>(mallocInfo.usmblks + mallocInfo.uordblks + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity());
+ if (totalUsedMemory > m_peakTotalUsedMemory)
+ m_peakTotalUsedMemory = totalUsedMemory;
+
+ unsigned totalCommittedMemory = BlackBerry::Platform::totalCommittedMemory();
+ if (totalCommittedMemory > m_peakTotalCommittedMemory)
+ m_peakTotalCommittedMemory = totalCommittedMemory;
+
+ struct stat processInfo;
+ if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo)) {
+ unsigned totalMappedMemory = static_cast<unsigned>(processInfo.st_size);
+ if (totalMappedMemory > m_peakTotalMappedMemory)
+ m_peakTotalMappedMemory = totalMappedMemory;
+ }
+}
+
+static String memoryPeaksToHtmlTable(MemoryTracker& memoryTracker)
+{
+ return String("<table class='fixed-table'><col width=75%><col width=25%>")
+ + numberToHTMLTr("Total used memory(malloc + JSC):", memoryTracker.peakTotalUsedMemory())
+ + numberToHTMLTr("Total committed memory:", memoryTracker.peakTotalCommittedMemory())
+ + numberToHTMLTr("Total mapped memory:", memoryTracker.peakTotalMappedMemory())
+ + "</table>";
+}
+
+static String memoryLivePage(String memoryLiveCommand)
+{
+ String page;
+
+ page = writeHeader("Memory Live Page")
+ + "<div class='box'><div class='box-title'>Memory Peaks</div>"
+ + "<div style='font-size:12px;color:#1BE0C9'>\"about:memory-live/start\": start tracking memory peaks.</div>"
+ + "<div style='font-size:12px;color:#1BE0C9'>\"about:memory-live\": show memory peaks every 30ms.</div>"
+ + "<div style='font-size:12px;color:#1BE0C9'>\"about:memory-live/stop\": stop tracking and show memory peaks.</div><br>";
+
+ MemoryTracker& memoryTracker = MemoryTracker::instance();
+ if (memoryLiveCommand.isEmpty()) {
+ if (!memoryTracker.isActive())
+ page += "<div style='font-size:15px;color:#E6F032'>Memory tracker isn't running, please use \"about:memory-live/start\" to start the tracker.</div>";
+ else {
+ page += memoryPeaksToHtmlTable(memoryTracker);
+ page += "<script type=\"text/_javascript_\">setInterval(function(){window.location.reload()},30);</script>";
+ }
+ } else if (equalIgnoringCase(memoryLiveCommand, "/start")) {
+ memoryTracker.start();
+ page += "<div style='font-size:15px;color:#E6F032'>Memory tracker is running.</div>";
+ } else if (equalIgnoringCase(memoryLiveCommand, "/stop")) {
+ if (!memoryTracker.isActive())
+ page += "<div style='font-size:15px;color:#E6F032'>Memory tracker isn't running.</div>";
+ else {
+ memoryTracker.stop();
+ page += memoryPeaksToHtmlTable(memoryTracker);
+ page += "<div style='font-size:15px;color:#E6F032'>Memory tracker is stopped.</div>";
+ }
+ } else
+ page += "<div style='font-size:15spx;color:#E6F032'>Unknown command! Please input a correct command!</div>";
+
+ page += "</div><br></div></body></html>";
+ return page;
+}
+#endif
+
static String cachePage(String cacheCommand)
{
String result;
@@ -409,6 +530,9 @@
if (BlackBerry::Platform::debugSetting() > 0 && equalIgnoringCase(aboutWhat, "config"))
return configPage();
+
+ if (aboutWhat.startsWith("memory-live"))
+ return memoryLivePage(aboutWhat.substring(11));
#endif
return String();