Title: [132725] trunk/Source/WebCore
Revision
132725
Author
loi...@chromium.org
Date
2012-10-27 08:11:30 -0700 (Sat, 27 Oct 2012)

Log Message

Web Inspector: instrument chromium GlyphCache. It keeps ~2mb.
https://bugs.webkit.org/show_bug.cgi?id=100515

Reviewed by Yury Semikhatsky.

I replaced old version with an abstract number with new one which precisely reports allocated SkGlyphCache objects and their sizes.

* inspector/InspectorMemoryAgent.cpp:
(WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
* platform/MemoryUsageSupport.cpp:
(WebCore::MemoryUsageSupport::reportMemoryUsage):
* platform/MemoryUsageSupport.h:
(MemoryUsageSupport):
* platform/PlatformMemoryInstrumentation.cpp:
(WebCore):
* platform/PlatformMemoryInstrumentation.h:
(PlatformMemoryTypes):
* platform/chromium/MemoryUsageSupportChromium.cpp:
(reportMemoryUsage):
(WebCore::reportGlyphCache):
(WebCore):
(WebCore::MemoryUsageSupport::reportMemoryUsage):
* platform/qt/MemoryUsageSupportQt.cpp:
(WebCore::MemoryUsageSupport::reportMemoryUsage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132724 => 132725)


--- trunk/Source/WebCore/ChangeLog	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/ChangeLog	2012-10-27 15:11:30 UTC (rev 132725)
@@ -1,3 +1,30 @@
+2012-10-26  Ilya Tikhonovsky  <loi...@chromium.org>
+
+        Web Inspector: instrument chromium GlyphCache. It keeps ~2mb.
+        https://bugs.webkit.org/show_bug.cgi?id=100515
+
+        Reviewed by Yury Semikhatsky.
+
+        I replaced old version with an abstract number with new one which precisely reports allocated SkGlyphCache objects and their sizes.
+
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
+        * platform/MemoryUsageSupport.cpp:
+        (WebCore::MemoryUsageSupport::reportMemoryUsage):
+        * platform/MemoryUsageSupport.h:
+        (MemoryUsageSupport):
+        * platform/PlatformMemoryInstrumentation.cpp:
+        (WebCore):
+        * platform/PlatformMemoryInstrumentation.h:
+        (PlatformMemoryTypes):
+        * platform/chromium/MemoryUsageSupportChromium.cpp:
+        (reportMemoryUsage):
+        (WebCore::reportGlyphCache):
+        (WebCore):
+        (WebCore::MemoryUsageSupport::reportMemoryUsage):
+        * platform/qt/MemoryUsageSupportQt.cpp:
+        (WebCore::MemoryUsageSupport::reportMemoryUsage):
+
 2012-10-26  Philip Rogers  <p...@google.com>
 
         Prevent NaN offset values in ElementTimeControl.

Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (132724 => 132725)


--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-10-27 15:11:30 UTC (rev 132725)
@@ -513,17 +513,6 @@
     domTreesIterator.visitMemoryCache();
 }
 
-static void addPlatformComponentsInfo(PassRefPtr<InspectorMemoryBlocks> children)
-{
-    Vector<MemoryUsageSupport::ComponentInfo> components;
-    MemoryUsageSupport::memoryUsageByComponents(components);
-    for (Vector<MemoryUsageSupport::ComponentInfo>::iterator it = components.begin(); it != components.end(); ++it) {
-        RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(it->m_name);
-        block->setSize(it->m_sizeInBytes);
-        children->addItem(block);
-    }
-}
-
 void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<InspectorMemoryBlock>& processMemory)
 {
     MemoryInstrumentationClientImpl memoryInstrumentationClient;
@@ -534,8 +523,7 @@
     reportRenderTreeInfo(memoryInstrumentationClient, m_page);
     collectDomTreeInfo(memoryInstrumentation, m_page); // FIXME: collect for all pages?
 
-    RefPtr<InspectorMemoryBlocks> children = InspectorMemoryBlocks::create();
-    addPlatformComponentsInfo(children);
+    MemoryUsageSupport::reportMemoryUsage(&memoryInstrumentation);
 
     memoryInstrumentation.addRootObject(this);
     memoryInstrumentation.addRootObject(memoryInstrumentation);
@@ -543,6 +531,7 @@
 
     m_inspectorClient->dumpUncountedAllocatedObjects(memoryInstrumentationClient.countedObjects());
 
+    RefPtr<InspectorMemoryBlocks> children = InspectorMemoryBlocks::create();
     MemoryUsageStatsGenerator statsGenerator(&memoryInstrumentationClient);
     statsGenerator.dump(children.get());
 

Modified: trunk/Source/WebCore/platform/MemoryUsageSupport.cpp (132724 => 132725)


--- trunk/Source/WebCore/platform/MemoryUsageSupport.cpp	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/MemoryUsageSupport.cpp	2012-10-27 15:11:30 UTC (rev 132725)
@@ -63,7 +63,7 @@
     return false;
 }
 
-void MemoryUsageSupport::memoryUsageByComponents(Vector<ComponentInfo>&)
+void MemoryUsageSupport::reportMemoryUsage(MemoryInstrumentation*)
 {
 }
 

Modified: trunk/Source/WebCore/platform/MemoryUsageSupport.h (132724 => 132725)


--- trunk/Source/WebCore/platform/MemoryUsageSupport.h	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/MemoryUsageSupport.h	2012-10-27 15:11:30 UTC (rev 132725)
@@ -61,16 +61,8 @@
     // false on platform specific error conditions.
     static bool processMemorySizesInBytes(size_t* privateBytes, size_t* sharedBytes);
 
-    class ComponentInfo {
-    public:
-        ComponentInfo(const String& name, size_t size) : m_name(name), m_sizeInBytes(size) { }
-
-        const String m_name;
-        size_t m_sizeInBytes;
-    };
-
-    // Reports private memory used by components in bytes.
-    static void memoryUsageByComponents(Vector<ComponentInfo>&);
+    // Reports memory objects used by platform.
+    static void reportMemoryUsage(MemoryInstrumentation*);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.cpp (132724 => 132725)


--- trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.cpp	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.cpp	2012-10-27 15:11:30 UTC (rev 132725)
@@ -35,5 +35,6 @@
 
 MemoryObjectType PlatformMemoryTypes::Image = "Page.Image";
 MemoryObjectType PlatformMemoryTypes::Loader = "Page.Loader";
+MemoryObjectType PlatformMemoryTypes::GlyphCache = "MemoryCache.GlyphCache";
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.h (132724 => 132725)


--- trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.h	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/PlatformMemoryInstrumentation.h	2012-10-27 15:11:30 UTC (rev 132725)
@@ -43,6 +43,7 @@
 public:
     static MemoryObjectType Image;
     static MemoryObjectType Loader;
+    static MemoryObjectType GlyphCache;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/chromium/MemoryUsageSupportChromium.cpp (132724 => 132725)


--- trunk/Source/WebCore/platform/chromium/MemoryUsageSupportChromium.cpp	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/chromium/MemoryUsageSupportChromium.cpp	2012-10-27 15:11:30 UTC (rev 132725)
@@ -31,9 +31,18 @@
 #include "config.h"
 #include "MemoryUsageSupport.h"
 
+#include "PlatformMemoryInstrumentation.h"
+#include <SkGlyphCache.h>
 #include <SkGraphics.h>
 #include <public/Platform.h>
 
+void reportMemoryUsage(const SkGlyphCache* const& glyphCache, WTF::MemoryObjectInfo* memoryObjectInfo)
+{
+    WTF::MemoryClassInfo info(memoryObjectInfo, glyphCache, WebCore::PlatformMemoryTypes::GlyphCache);
+    info.addMember(&glyphCache->getDescriptor());
+    info.addMember(glyphCache->getScalerContext());
+}
+
 namespace WebCore {
 
 int MemoryUsageSupport::memoryUsageMB()
@@ -66,10 +75,16 @@
     return WebKit::Platform::current()->processMemorySizesInBytes(privateBytes, sharedBytes);
 }
 
-void MemoryUsageSupport::memoryUsageByComponents(Vector<ComponentInfo>& components)
+static bool reportGlyphCache(SkGlyphCache* glyphCache, void* ctx)
 {
-    size_t size = SkGraphics::GetFontCacheUsed();
-    components.append(ComponentInfo("GlyphCache", size));
+    MemoryInstrumentation* memoryInstrumentation = reinterpret_cast<MemoryInstrumentation*>(ctx);
+    memoryInstrumentation->addRootObject(glyphCache);
+    return false;
 }
 
+void MemoryUsageSupport::reportMemoryUsage(MemoryInstrumentation* memoryInstrumentation)
+{
+    SkGlyphCache::VisitAllCaches(reportGlyphCache, memoryInstrumentation);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/qt/MemoryUsageSupportQt.cpp (132724 => 132725)


--- trunk/Source/WebCore/platform/qt/MemoryUsageSupportQt.cpp	2012-10-27 07:01:34 UTC (rev 132724)
+++ trunk/Source/WebCore/platform/qt/MemoryUsageSupportQt.cpp	2012-10-27 15:11:30 UTC (rev 132725)
@@ -111,7 +111,7 @@
     return false;
 }
 
-void MemoryUsageSupport::memoryUsageByComponents(Vector<ComponentInfo>&)
+void MemoryUsageSupport::reportMemoryUsage(MemoryInstrumentation* memoryInstrumentation)
 {
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to