本文整理汇总了C++中MemoryCache类的典型用法代码示例。如果您正苦于以下问题:C++ MemoryCache类的具体用法?C++ MemoryCache怎么用?C++ MemoryCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemoryCache类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCapacities
void WebCache::setCapacities(
size_t minDeadCapacity, size_t maxDeadCapacity, size_t capacity)
{
MemoryCache* cache = WebCore::memoryCache();
if (cache)
cache->setCapacities(static_cast<unsigned>(minDeadCapacity), static_cast<unsigned>(maxDeadCapacity), static_cast<unsigned>(capacity));
}
示例2: memoryCache
void WebCache::getResourceTypeStats(ResourceTypeStats* result)
{
MemoryCache* cache = memoryCache();
if (cache) {
MemoryCache::Statistics stats = cache->getStatistics();
ToResourceTypeStat(stats.images, result->images);
ToResourceTypeStat(stats.cssStyleSheets, result->cssStyleSheets);
ToResourceTypeStat(stats.scripts, result->scripts);
ToResourceTypeStat(stats.fonts, result->fonts);
} else
memset(result, 0, sizeof(WebCache::ResourceTypeStats));
}
示例3: ASSERT
void WebCache::getUsageStats(UsageStats* result)
{
ASSERT(result);
MemoryCache* cache = WebCore::memoryCache();
if (cache) {
result->minDeadCapacity = cache->minDeadCapacity();
result->maxDeadCapacity = cache->maxDeadCapacity();
result->capacity = cache->capacity();
result->liveSize = cache->liveSize();
result->deadSize = cache->deadSize();
} else
memset(result, 0, sizeof(UsageStats));
}
示例4: memoryPage
static String memoryPage()
{
String page;
page = writeHeader("Memory")
+ "<div class=\"box\"><div class=\"box-title\">Cache Information<br><div style='font-size:11px;color:#A8A8A8'>Size, Living, and Decoded are expressed in KB.</div><br></div><table class='fixed-table'><col width=75%><col width=25%>";
// generate cache information
MemoryCache* cacheInc = memoryCache();
MemoryCache::Statistics cacheStat = cacheInc->getStatistics();
page += "<tr> <th align=left>Item</th> <th align=left>Count</th> <th align=left>Size</th> <th align=left>Living</th> <th align=left>Decoded</th></tr>";
MemoryCache::TypeStatistic total;
total.count = cacheStat.images.count + cacheStat.cssStyleSheets.count
+ cacheStat.scripts.count + cacheStat.xslStyleSheets.count + cacheStat.fonts.count;
total.size = cacheInc->totalSize();
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", cacheStat.images);
page += cacheTypeStatisticToHTMLTr("CSS Style Sheets", cacheStat.cssStyleSheets);
page += cacheTypeStatisticToHTMLTr("Scripts", cacheStat.scripts);
#if ENABLE(XSLT)
page += cacheTypeStatisticToHTMLTr("XSL Style Sheets", cacheStat.xslStyleSheets);
#endif
page += cacheTypeStatisticToHTMLTr("Fonts", cacheStat.fonts);
page += "</table></div><br>";
#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
// JS engine memory usage.
JSC::GlobalMemoryStatistics jscMemoryStat = JSC::globalMemoryStatistics();
JSC::Heap& mainHeap = JSDOMWindow::commonJSGlobalData()->heap;
OwnPtr<JSC::TypeCountSet> objectTypeCounts = mainHeap.objectTypeCounts();
OwnPtr<JSC::TypeCountSet> protectedObjectTypeCounts = mainHeap.protectedObjectTypeCounts();
// Malloc info.
struct mallinfo mallocInfo = mallinfo();
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 used memory (malloc + JSC)", mallocInfo.usmblks + mallocInfo.uordblks + jscMemoryStat.stackBytes + jscMemoryStat.JITBytes + mainHeap.capacity());
if (unsigned totalCommittedMemoryOfChromeProcess = BlackBerry::Platform::totalCommittedMemoryOfChromeProcess()) {
page += numberToHTMLTr("Total committed memory of tab process", BlackBerry::Platform::totalCommittedMemoryOfCurrentProcess());
page += numberToHTMLTr("Total committed memory of chrome process", totalCommittedMemoryOfChromeProcess);
} else
page += numberToHTMLTr("Total committed memory", BlackBerry::Platform::totalCommittedMemoryOfCurrentProcess());
struct stat processInfo;
if (!stat(String::format("/proc/%u/as", getpid()).latin1().data(), &processInfo))
page += numberToHTMLTr("Total mapped memory", processInfo.st_size);
page += numberToHTMLTr("System free memory", BlackBerry::Platform::systemFreeMemory());
page += "</table></div><br>";
page += "<div class='box'><div class='box-title'>JS engine memory usage</div><table class='fixed-table'><col width=75%><col width=25%>";
page += numberToHTMLTr("Stack size", jscMemoryStat.stackBytes);
page += numberToHTMLTr("JIT memory usage", jscMemoryStat.JITBytes);
page += numberToHTMLTr("Main heap capacity", mainHeap.capacity());
page += numberToHTMLTr("Main heap size", mainHeap.size());
page += numberToHTMLTr("Object count", mainHeap.objectCount());
page += numberToHTMLTr("Global object count", mainHeap.globalObjectCount());
page += numberToHTMLTr("Protected object count", mainHeap.protectedObjectCount());
page += numberToHTMLTr("Protected global object count", mainHeap.protectedGlobalObjectCount());
page += "</table></div><br>";
page += "<div class='box'><div class='box-title'>JS object type counts</div><table class='fixed-table'><col width=75%><col width=25%>";
dumpJSCTypeCountSetToTableHTML(page, objectTypeCounts.get());
page += "</table></div><br>";
page += "<div class='box'><div class='box-title'>JS protected object type counts</div><table class='fixed-table'><col width=75%><col width=25%>";
dumpJSCTypeCountSetToTableHTML(page, protectedObjectTypeCounts.get());
page += "</table></div><br>";
page += "<div class='box'><div class='box-title'>Malloc Information</div><table class='fixed-table'><col width=75%><col width=25%>";
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);
page += "</table></div>";
#endif
//.........这里部分代码省略.........
示例5: clear
void WebCache::clear()
{
MemoryCache* cache = WebCore::memoryCache();
if (cache)
cache->evictResources();
}
示例6: memoryPage
String memoryPage()
{
String page;
// generate memory information
page = String("<html><head><title>BlackBerry Browser Memory Information</title></head><body><h2>BlackBerry Browser Memory Information</h2>");
// generate cache information
MemoryCache* cacheInc = memoryCache();
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 = cacheStat.images.count + cacheStat.cssStyleSheets.count
+ cacheStat.scripts.count + cacheStat.xslStyleSheets.count + cacheStat.fonts.count;
total.size = cacheInc->totalSize();
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", cacheStat.images);
page += cacheTypeStatisticToHTMLTr("CSS Style Sheets", cacheStat.cssStyleSheets);
page += cacheTypeStatisticToHTMLTr("Scripts", cacheStat.scripts);
#if ENABLE(XSLT)
page += cacheTypeStatisticToHTMLTr("XSL Style Sheets", cacheStat.xslStyleSheets);
#endif
page += cacheTypeStatisticToHTMLTr("Fonts", cacheStat.fonts);
page += "</table>";
#if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
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>";
#endif
page += "</body></html>";
return page;
}