[BlackBerry] Add malloc info to about:memory page


Patch by Yong Li <yoli@rim.com> on 2012-05-29
Reviewed by Rob Buis.

Detailed malloc info can tell us how much memory
in the heaps is being in use.

* WebCoreSupport/AboutData.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5f24e3f2
2012-05-29 Yong Li <yoli@rim.com>
[BlackBerry] Add malloc info to about:memory page
Reviewed by Rob Buis.
Detailed malloc info can tell us how much memory
in the heaps is being in use.
* WebCoreSupport/AboutData.cpp:
2012-05-29 Arvid Nilsson <anilsson@rim.com>
[BlackBerry] Make DefaultTapHighlight use the new WebOverlay API
......@@ -19,13 +19,15 @@
#include "config.h"
#include "AboutData.h"
#include "CString.h"
#include "MemoryCache.h"
#include "SurfacePool.h"
#include "WebKitVersion.h"
#include <process.h>
#include <BlackBerryPlatformSettings.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <wtf/Platform.h>
namespace WebCore {
......@@ -195,31 +197,57 @@ String memoryPage()
// generate cache information
MemoryCache* cacheInc = memoryCache();
MemoryCache::Statistics stat = cacheInc->getStatistics();
MemoryCache::Statistics cacheStat = cacheInc->getStatistics();
page += String("<h2>Cache Information</h2>")
+ "<table align=\"center\" rules=\"all\"><tr> <th>Item</th> <th>Count</th> <th>Size<br>KB</th> <th>Living<br>KB</th> <th>Decoded<br>KB</th></tr>";
MemoryCache::TypeStatistic total;
total.count = stat.images.count + stat.cssStyleSheets.count
+ stat.scripts.count + stat.xslStyleSheets.count + stat.fonts.count;
total.count = cacheStat.images.count + cacheStat.cssStyleSheets.count
+ cacheStat.scripts.count + cacheStat.xslStyleSheets.count + cacheStat.fonts.count;
total.size = cacheInc->totalSize();
total.liveSize = stat.images.liveSize + stat.cssStyleSheets.liveSize
+ stat.scripts.liveSize + stat.xslStyleSheets.liveSize + stat.fonts.liveSize;
total.decodedSize = stat.images.decodedSize
+ stat.cssStyleSheets.decodedSize + stat.scripts.decodedSize
+ stat.xslStyleSheets.decodedSize + stat.fonts.decodedSize;
total.liveSize = cacheStat.images.liveSize + cacheStat.cssStyleSheets.liveSize
+ cacheStat.scripts.liveSize + cacheStat.xslStyleSheets.liveSize + cacheStat.fonts.liveSize;
total.decodedSize = cacheStat.images.decodedSize
+ cacheStat.cssStyleSheets.decodedSize + cacheStat.scripts.decodedSize
+ cacheStat.xslStyleSheets.decodedSize + cacheStat.fonts.decodedSize;
page += cacheTypeStatisticToHTMLTr("Total", total);
page += cacheTypeStatisticToHTMLTr("Images", stat.images);
page += cacheTypeStatisticToHTMLTr("CSS Style Sheets", stat.cssStyleSheets);
page += cacheTypeStatisticToHTMLTr("Scripts", stat.scripts);
page += cacheTypeStatisticToHTMLTr("Images", cacheStat.images);
page += cacheTypeStatisticToHTMLTr("CSS Style Sheets", cacheStat.cssStyleSheets);
page += cacheTypeStatisticToHTMLTr("Scripts", cacheStat.scripts);
page += cacheTypeStatisticToHTMLTr("XSL Style Sheets", stat.xslStyleSheets);
page += cacheTypeStatisticToHTMLTr("XSL Style Sheets", cacheStat.xslStyleSheets);
page += cacheTypeStatisticToHTMLTr("Fonts", stat.fonts);
page += cacheTypeStatisticToHTMLTr("Fonts", cacheStat.fonts);
page += "</table></body></html>";
page += "</table>";
struct mallinfo mallocInfo = mallinfo();
page += String("<h2>Malloc Information</h2>") + "<table align=\"center\" rules=\"all\">";
page += numberToHTMLTr("Total space in use", mallocInfo.usmblks + mallocInfo.uordblks);
page += numberToHTMLTr("Total space in free blocks", mallocInfo.fsmblks + mallocInfo.fordblks);
page += numberToHTMLTr("Size of the arena", mallocInfo.arena);
page += numberToHTMLTr("Number of big blocks in use", mallocInfo.ordblks);
page += numberToHTMLTr("Number of small blocks in use", mallocInfo.smblks);
page += numberToHTMLTr("Number of header blocks in use", mallocInfo.hblks);
page += numberToHTMLTr("Space in header block headers", mallocInfo.hblkhd);
page += numberToHTMLTr("Space in small blocks in use", mallocInfo.usmblks);
page += numberToHTMLTr("Memory in free small blocks", mallocInfo.fsmblks);
page += numberToHTMLTr("Space in big blocks in use", mallocInfo.uordblks);
page += numberToHTMLTr("Memory in free big blocks", mallocInfo.fordblks);
struct stat processInfo;
if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo))
page += numberToHTMLTr("Process total mapped memory", processInfo.st_size);
page += "</table>";
page += "</body></html>";
return page;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment