Web Inspector: convert manual size calculation of different WebKit things into Memory...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2012 13:51:55 +0000 (13:51 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2012 13:51:55 +0000 (13:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99309

Reviewed by Yury Semikhatsky.

JSHeap, DOMStorage and HeapProfiler data were counted manually.
Now we count the sizes more generic way.

Source/WebCore:

* dom/WebCoreMemoryInstrumentation.cpp:
* dom/WebCoreMemoryInstrumentation.h:
(WebCoreMemoryTypes): new string identifiers were added for Inspector's data.
* inspector/InspectorBaseAgent.cpp:
(WebCore::InspectorBaseAgentInterface::InspectorBaseAgentInterface): common data members were moved from template to base class.
(WebCore::InspectorBaseAgentInterface::reportMemoryUsage): NMI instrumentation was added to the base template.
* inspector/InspectorBaseAgent.h:
(InspectorBaseAgentInterface): ditto
(WebCore::InspectorBaseAgent::InspectorBaseAgent): ditto
* inspector/InspectorController.cpp:
(WebCore::InspectorController::reportMemoryUsage): NMI instrumentation was added to the class.
* inspector/InspectorController.h:
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::reportMemoryUsage): NMI instrumentation was added to the class.
* inspector/InspectorDOMStorageAgent.h:
* inspector/InspectorDOMStorageResource.cpp:
(WebCore::InspectorDOMStorageResource::reportMemoryUsage): NMI instrumentation was added to the class.
* inspector/InspectorDOMStorageResource.h:
* inspector/InspectorMemoryAgent.cpp:
(WebCore::reportJSHeapInfo): these methods now use MemoryInstrumentation for reporting the size of underlying data.
(WebCore::reportRenderTreeInfo):
(WebCore::collectDomTreeInfo):
(WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
(WebCore::InspectorMemoryAgent::reportMemoryUsage): NMI instrumentation was added to the class.
* inspector/InspectorMemoryAgent.h:
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::reportMemoryUsage):
* inspector/InspectorProfilerAgent.h:
(InspectorProfilerAgent): NMI instrumentation was added to the class.
* inspector/MemoryInstrumentationImpl.cpp: allocatedObjects map was converted from InspectorMemoryAgent::getProcessMemoryDistribution local variable to member variable.
(WebCore::MemoryInstrumentationClientImpl::checkCountedObject):
(WebCore::MemoryInstrumentationClientImpl::reportMemoryUsage): NMI instrumentation was added to the class.
(WebCore::MemoryInstrumentationImpl::reportMemoryUsage): NMI instrumentation was added to the class.
* inspector/MemoryInstrumentationImpl.h:
(WebCore::MemoryInstrumentationClientImpl::MemoryInstrumentationClientImpl):
(WebCore::MemoryInstrumentationClientImpl::allocatedObjects):
(WebCore::MemoryInstrumentationClientImpl::checkInstrumentedObjects):
* inspector/front-end/NativeMemorySnapshotView.js:
(WebInspector.MemoryBlockViewProperties._initialize):
(WebInspector.NativeMemoryBarChart.prototype._updateView):
* page/Page.cpp:
(WebCore::Page::reportMemoryUsage): NMI instrumentation was added to the class.
* page/Page.h:

Source/WTF:

* wtf/MemoryInstrumentation.h: calculateContainerSize were removed.
* wtf/MemoryInstrumentationSequence.h: empty instrumentations were added for 'const char*' and 'const void*' sequences.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131299 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/MemoryInstrumentation.h
Source/WTF/wtf/MemoryInstrumentationSequence.h
Source/WebCore/ChangeLog
Source/WebCore/dom/WebCoreMemoryInstrumentation.cpp
Source/WebCore/dom/WebCoreMemoryInstrumentation.h
Source/WebCore/inspector/InspectorBaseAgent.cpp
Source/WebCore/inspector/InspectorBaseAgent.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDOMStorageAgent.cpp
Source/WebCore/inspector/InspectorDOMStorageAgent.h
Source/WebCore/inspector/InspectorDOMStorageResource.cpp
Source/WebCore/inspector/InspectorDOMStorageResource.h
Source/WebCore/inspector/InspectorMemoryAgent.cpp
Source/WebCore/inspector/InspectorMemoryAgent.h
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/InspectorProfilerAgent.h
Source/WebCore/inspector/MemoryInstrumentationImpl.cpp
Source/WebCore/inspector/MemoryInstrumentationImpl.h
Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h

index 44612cb..ee3fdec 100644 (file)
@@ -1,3 +1,16 @@
+2012-10-15  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: convert manual size calculation of different WebKit things into MemoryInstrumentation.
+        https://bugs.webkit.org/show_bug.cgi?id=99309
+
+        Reviewed by Yury Semikhatsky.
+
+        JSHeap, DOMStorage and HeapProfiler data were counted manually.
+        Now we count the sizes more generic way.
+
+        * wtf/MemoryInstrumentation.h: calculateContainerSize were removed.
+        * wtf/MemoryInstrumentationSequence.h: empty instrumentations were added for 'const char*' and 'const void*' sequences.
+
 2012-10-12  Anders Carlsson  <andersca@apple.com>
 
         Move QDataStream functions into HistoryItemQt.cpp
index 367e2bc..0b7c217 100644 (file)
@@ -102,8 +102,6 @@ public:
         processDeferredInstrumentedPointers();
     }
 
-    template<typename Container> static size_t calculateContainerSize(const Container&, bool contentOnly = false);
-
 protected:
     class InstrumentedPointerBase {
     public:
@@ -260,12 +258,6 @@ void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, Memor
     countObjectSize(ownerObjectType, size);
 }
 
-template<typename Container>
-size_t MemoryInstrumentation::calculateContainerSize(const Container& container, bool contentOnly)
-{
-    return (contentOnly ? 0 : sizeof(container)) + container.capacity() * sizeof(typename Container::ValueType);
-}
-
 template<typename T>
 void MemoryInstrumentation::InstrumentedPointer<T>::process(MemoryInstrumentation* memoryInstrumentation)
 {
index 64e8898..bbf204c 100644 (file)
@@ -59,6 +59,14 @@ template<> struct SequenceMemoryInstrumentationTraits<char*> {
     template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
 };
 
+template<> struct SequenceMemoryInstrumentationTraits<const char*> {
+    template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
+};
+
+template<> struct SequenceMemoryInstrumentationTraits<const void*> {
+    template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
+};
+
 template<typename ValueType, typename I> void reportSequenceMemoryUsage(I begin, I end, MemoryClassInfo& info)
 {
     // Check if type is convertible to integer to handle iteration through enum values.
index 8ba7422..733e284 100644 (file)
@@ -1,3 +1,57 @@
+2012-10-15  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: convert manual size calculation of different WebKit things into MemoryInstrumentation.
+        https://bugs.webkit.org/show_bug.cgi?id=99309
+
+        Reviewed by Yury Semikhatsky.
+
+        JSHeap, DOMStorage and HeapProfiler data were counted manually.
+        Now we count the sizes more generic way.
+
+        * dom/WebCoreMemoryInstrumentation.cpp:
+        * dom/WebCoreMemoryInstrumentation.h:
+        (WebCoreMemoryTypes): new string identifiers were added for Inspector's data.
+        * inspector/InspectorBaseAgent.cpp:
+        (WebCore::InspectorBaseAgentInterface::InspectorBaseAgentInterface): common data members were moved from template to base class.
+        (WebCore::InspectorBaseAgentInterface::reportMemoryUsage): NMI instrumentation was added to the base template.
+        * inspector/InspectorBaseAgent.h:
+        (InspectorBaseAgentInterface): ditto
+        (WebCore::InspectorBaseAgent::InspectorBaseAgent): ditto
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::reportMemoryUsage): NMI instrumentation was added to the class.
+        * inspector/InspectorController.h:
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::reportMemoryUsage): NMI instrumentation was added to the class.
+        * inspector/InspectorDOMStorageAgent.h:
+        * inspector/InspectorDOMStorageResource.cpp:
+        (WebCore::InspectorDOMStorageResource::reportMemoryUsage): NMI instrumentation was added to the class.
+        * inspector/InspectorDOMStorageResource.h:
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore::reportJSHeapInfo): these methods now use MemoryInstrumentation for reporting the size of underlying data.
+        (WebCore::reportRenderTreeInfo):
+        (WebCore::collectDomTreeInfo):
+        (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
+        (WebCore::InspectorMemoryAgent::reportMemoryUsage): NMI instrumentation was added to the class.
+        * inspector/InspectorMemoryAgent.h:
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::reportMemoryUsage):
+        * inspector/InspectorProfilerAgent.h:
+        (InspectorProfilerAgent): NMI instrumentation was added to the class.
+        * inspector/MemoryInstrumentationImpl.cpp: allocatedObjects map was converted from InspectorMemoryAgent::getProcessMemoryDistribution local variable to member variable.
+        (WebCore::MemoryInstrumentationClientImpl::checkCountedObject):
+        (WebCore::MemoryInstrumentationClientImpl::reportMemoryUsage): NMI instrumentation was added to the class.
+        (WebCore::MemoryInstrumentationImpl::reportMemoryUsage): NMI instrumentation was added to the class.
+        * inspector/MemoryInstrumentationImpl.h:
+        (WebCore::MemoryInstrumentationClientImpl::MemoryInstrumentationClientImpl):
+        (WebCore::MemoryInstrumentationClientImpl::allocatedObjects):
+        (WebCore::MemoryInstrumentationClientImpl::checkInstrumentedObjects):
+        * inspector/front-end/NativeMemorySnapshotView.js:
+        (WebInspector.MemoryBlockViewProperties._initialize):
+        (WebInspector.NativeMemoryBarChart.prototype._updateView):
+        * page/Page.cpp:
+        (WebCore::Page::reportMemoryUsage): NMI instrumentation was added to the class.
+        * page/Page.h:
+
 2012-10-15  Kent Tamura  <tkent@chromium.org>
 
         Improve code of LocaleMac.mm
index 6edc539..cd46980 100644 (file)
@@ -33,6 +33,7 @@
 
 namespace WebCore {
 
+MemoryObjectType WebCoreMemoryTypes::Page = "Page";
 MemoryObjectType WebCoreMemoryTypes::DOM = "Page.DOM";
 MemoryObjectType WebCoreMemoryTypes::CSS = "Page.CSS";
 MemoryObjectType WebCoreMemoryTypes::Binding = "Page.Binding";
@@ -51,4 +52,21 @@ MemoryObjectType WebCoreMemoryTypes::CachedResourceXSLT = "MemoryCache.XSLT";
 MemoryObjectType WebCoreMemoryTypes::ExternalStrings = "JSExternalResources.Strings";
 MemoryObjectType WebCoreMemoryTypes::ExternalArrays = "JSExternalResources.Arrays";
 
+MemoryObjectType WebCoreMemoryTypes::Inspector = "WebInspector";
+MemoryObjectType WebCoreMemoryTypes::InspectorController = "WebInspector.Controller";
+MemoryObjectType WebCoreMemoryTypes::InspectorMemoryAgent = "WebInspector.MemoryAgent";
+MemoryObjectType WebCoreMemoryTypes::InspectorDOMStorageAgent = "WebInspector.DOMStorageAgent";
+MemoryObjectType WebCoreMemoryTypes::InspectorDOMStorageResources = "WebInspector.DOMStorageAgent.Resources";
+MemoryObjectType WebCoreMemoryTypes::InspectorProfilerAgent = "WebInspector.ProfilerAgent";
+
+MemoryObjectType WebCoreMemoryTypes::JSHeapUsed = "JSHeap.Used";
+MemoryObjectType WebCoreMemoryTypes::JSHeapUnused = "JSHeap.Unused";
+
+MemoryObjectType WebCoreMemoryTypes::DOMStorageCache = "DOMStorageCache";
+
+MemoryObjectType WebCoreMemoryTypes::RenderTreeUsed = "RenderTree.Used";
+MemoryObjectType WebCoreMemoryTypes::RenderTreeUnused = "RenderTree.Unused";
+
+MemoryObjectType WebCoreMemoryTypes::ProcessPrivateMemory = "ProcessPrivateMemory";
+
 } // namespace WebCore
index 0bcf09d..80d3cab 100644 (file)
@@ -41,6 +41,7 @@ using WTF::MemoryObjectType;
 
 class WebCoreMemoryTypes : public PlatformMemoryTypes {
 public:
+    static MemoryObjectType Page;
     static MemoryObjectType DOM;
     static MemoryObjectType CSS;
     static MemoryObjectType Binding;
@@ -58,6 +59,23 @@ public:
 
     static MemoryObjectType ExternalStrings;
     static MemoryObjectType ExternalArrays;
+
+    static MemoryObjectType Inspector;
+    static MemoryObjectType InspectorController;
+    static MemoryObjectType InspectorMemoryAgent;
+    static MemoryObjectType InspectorDOMStorageAgent;
+    static MemoryObjectType InspectorDOMStorageResources;
+    static MemoryObjectType InspectorProfilerAgent;
+
+    static MemoryObjectType JSHeapUsed;
+    static MemoryObjectType JSHeapUnused;
+
+    static MemoryObjectType DOMStorageCache;
+
+    static MemoryObjectType RenderTreeUsed;
+    static MemoryObjectType RenderTreeUnused;
+
+    static MemoryObjectType ProcessPrivateMemory;
 };
 
 } // namespace WebCore
index f3fd92b..ffa9555 100644 (file)
 
 #include "InspectorBaseAgent.h"
 
+#include "WebCoreMemoryInstrumentation.h"
+
 namespace WebCore {
 
-InspectorBaseAgentInterface::InspectorBaseAgentInterface(const String& name)
-    : m_name(name)
+InspectorBaseAgentInterface::InspectorBaseAgentInterface(const String& name, InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
+    : m_instrumentingAgents(instrumentingAgents)
+    , m_state(inspectorState)
+    , m_name(name)
 {
 }
 
@@ -45,6 +49,14 @@ InspectorBaseAgentInterface::~InspectorBaseAgentInterface()
 {
 }
 
+void InspectorBaseAgentInterface::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector);
+    info.addMember(m_name);
+    info.addWeakPointer(m_instrumentingAgents);
+    info.addWeakPointer(m_state);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 800f967..849763f 100644 (file)
@@ -32,6 +32,7 @@
 #define InspectorBaseAgent_h
 
 #include "InspectorBackendDispatcher.h"
+#include <wtf/Forward.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -43,7 +44,7 @@ class InstrumentingAgents;
 
 class InspectorBaseAgentInterface {
 public:
-    explicit InspectorBaseAgentInterface(const String& name);
+    InspectorBaseAgentInterface(const String&, InstrumentingAgents*, InspectorState*);
     virtual ~InspectorBaseAgentInterface();
 
     virtual void setFrontend(InspectorFrontend*) { }
@@ -53,6 +54,13 @@ public:
     virtual void discardAgent() { }
 
     String name() { return m_name; }
+
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
+protected:
+    InstrumentingAgents* m_instrumentingAgents;
+    InspectorState* m_state;
+
 private:
     String m_name;
 };
@@ -69,14 +77,9 @@ public:
 
 protected:
     InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
-        : InspectorBaseAgentInterface(name)
-        , m_instrumentingAgents(instrumentingAgents)
-        , m_state(inspectorState)
+        : InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState)
     {
     }
-
-    InstrumentingAgents* m_instrumentingAgents;
-    InspectorState* m_state;
 };
 
 } // namespace WebCore
index 6095519..8bad7cc 100644 (file)
@@ -71,6 +71,8 @@
 #include "Page.h"
 #include "ScriptObject.h"
 #include "Settings.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/UnusedParam.h>
 
 namespace WebCore {
@@ -114,7 +116,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     OwnPtr<InspectorDOMStorageAgent> domStorageAgentPtr(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get()));
     InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
     m_agents.append(domStorageAgentPtr.release());
-    m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), inspectorClient, m_state.get(), m_page, domStorageAgent));
+    m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), inspectorClient, m_state.get(), m_page));
     m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), InspectorTimelineAgent::PageInspector,
        inspectorClient));
     m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent));
@@ -380,6 +382,32 @@ void InspectorController::setResourcesDataSizeLimitsFromInternals(int maximumRes
     m_resourceAgent->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
 }
 
+void InspectorController::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorController);
+    info.addMember(m_inspectorAgent);
+    info.addMember(m_instrumentingAgents);
+    info.addMember(m_injectedScriptManager);
+    info.addMember(m_state);
+    info.addMember(m_overlay);
+
+    info.addMember(m_inspectorAgent);
+    info.addMember(m_domAgent);
+    info.addMember(m_resourceAgent);
+    info.addMember(m_pageAgent);
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    info.addMember(m_debuggerAgent);
+    info.addMember(m_profilerAgent);
+#endif
+
+    info.addMember(m_inspectorBackendDispatcher);
+    info.addMember(m_inspectorFrontendClient);
+    info.addMember(m_inspectorFrontend);
+    info.addMember(m_page);
+    info.addMember(m_inspectorClient);
+    info.addMember(m_agents);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 82a2638..2e89092 100644 (file)
@@ -114,6 +114,8 @@ public:
     InspectorClient* inspectorClient() const { return m_inspectorClient; }
     InspectorPageAgent* pageAgent() const { return m_pageAgent; }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     InspectorController(Page*, InspectorClient*);
 
index c32ea29..ebdf1f3 100644 (file)
@@ -45,7 +45,9 @@
 #include "Storage.h"
 #include "StorageArea.h"
 #include "VoidCallback.h"
+#include "WebCoreMemoryInstrumentation.h"
 
+#include <wtf/MemoryInstrumentationHashMap.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -214,15 +216,14 @@ void InspectorDOMStorageAgent::clearResources()
     m_resources.clear();
 }
 
-size_t InspectorDOMStorageAgent::memoryBytesUsedByStorageCache() const
+void InspectorDOMStorageAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    size_t size = 0;
-    for (DOMStorageResourcesMap::const_iterator it = m_resources.begin(); it != m_resources.end(); ++it)
-        size += it->value->storageArea()->memoryBytesUsedByCache();
-    return size;
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorDOMStorageAgent);
+    InspectorBaseAgent<InspectorDOMStorageAgent>::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_resources);
+    info.addMember(m_frontend);
 }
 
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index a4f87b0..1822c6a 100644 (file)
@@ -78,8 +78,7 @@ public:
     void didUseDOMStorage(StorageArea*, bool isLocalStorage, Frame*);
     void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
 
-    // Called from InspectorMemoryAgent
-    size_t memoryBytesUsedByStorageCache() const;
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
 
 private:
     InspectorDOMStorageAgent(InstrumentingAgents*, InspectorState*);
index f7a8368..029e392 100644 (file)
@@ -85,6 +85,16 @@ void InspectorDOMStorageResource::unbind()
     m_frontend = 0;
 }
 
+void InspectorDOMStorageResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorDOMStorageResources);
+    info.addMember(m_storageArea);
+    info.addMember(m_frame);
+    info.addMember(m_frontend);
+    info.addMember(m_id);
+    info.addPrivateBuffer(m_storageArea->memoryBytesUsedByCache());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index ac059cb..10d46d7 100644 (file)
@@ -58,6 +58,8 @@ public:
     StorageArea* storageArea() const { return m_storageArea.get(); }
     Frame* frame() const { return m_frame.get(); }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     InspectorDOMStorageResource(StorageArea*, bool isLocalStorage, Frame*);
 
index 41ad843..badcb79 100644 (file)
@@ -75,20 +75,6 @@ typedef WebCore::TypeBuilder::Array<InspectorMemoryBlock> InspectorMemoryBlocks;
 
 namespace WebCore {
 
-namespace MemoryBlockName {
-static const char jsHeapAllocated[] = "JSHeapAllocated";
-static const char jsHeapUsed[] = "JSHeapUsed";
-static const char inspectorData[] = "InspectorData";
-static const char inspectorDOMData[] = "InspectorDOMData";
-static const char inspectorJSHeapData[] = "InspectorJSHeapData";
-static const char processPrivateMemory[] = "ProcessPrivateMemory";
-
-static const char renderTreeUsed[] = "RenderTreeUsed";
-static const char renderTreeAllocated[] = "RenderTreeAllocated";
-
-static const char domStorageCache[] = "DOMStorageCache";
-}
-
 namespace {
 
 class MemoryUsageStatsGenerator {
@@ -134,10 +120,12 @@ private:
         String typeName = objectTypes[index];
         RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(typeName);
         block->setSize(m_sizesMap.get(typeName));
+        String prefix = typeName;
+        prefix.append('.');
         array->addItem(block);
         ++index;
         RefPtr<InspectorMemoryBlocks> children;
-        while (index < objectTypes.size() && objectTypes[index].startsWith(typeName)) {
+        while (index < objectTypes.size() && objectTypes[index].startsWith(prefix)) {
             if (!children)
                 children = InspectorMemoryBlocks::create();
             index = buildObjectForIndex(index, objectTypes, children.get());
@@ -420,38 +408,6 @@ private:
     mutable MemoryClassInfo* m_memoryClassInfo;
 };
 
-class InspectorDataCounter {
-public:
-    void addComponent(const String& name, size_t size)
-    {
-        m_components.append(ComponentInfo(name, size));
-    }
-
-    PassRefPtr<InspectorMemoryBlock> dumpStatistics()
-    {
-        size_t totalSize = 0;
-        RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(MemoryBlockName::inspectorData);
-        for (Vector<ComponentInfo>::iterator it = m_components.begin(); it != m_components.end(); ++it) {
-            RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(it->m_name);
-            block->setSize(it->m_size);
-            totalSize += it->m_size;
-        }
-        block->setSize(totalSize);
-        return block;
-    }
-
-private:
-    class ComponentInfo {
-    public:
-        ComponentInfo(const String& name, size_t size) : m_name(name), m_size(size) { }
-
-        const String m_name;
-        size_t m_size;
-    };
-
-    Vector<ComponentInfo> m_components;
-};
-
 } // namespace
 
 InspectorMemoryAgent::~InspectorMemoryAgent()
@@ -475,44 +431,28 @@ void InspectorMemoryAgent::getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Arr
     strings = counterVisitor.strings();
 }
 
-static PassRefPtr<InspectorMemoryBlock> jsHeapInfo()
+static void reportJSHeapInfo(WTF::MemoryInstrumentationClient& memoryInstrumentationClient)
 {
     HeapInfo info;
     ScriptGCEvent::getHeapSize(info);
 
-    RefPtr<InspectorMemoryBlock> jsHeapAllocated = InspectorMemoryBlock::create().setName(MemoryBlockName::jsHeapAllocated);
-    jsHeapAllocated->setSize(static_cast<int>(info.totalJSHeapSize));
-
-    RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = InspectorMemoryBlocks::create();
-    RefPtr<InspectorMemoryBlock> jsHeapUsed = InspectorMemoryBlock::create().setName(MemoryBlockName::jsHeapUsed);
-    jsHeapUsed->setSize(static_cast<int>(info.usedJSHeapSize));
-    children->addItem(jsHeapUsed);
-
-    jsHeapAllocated->setChildren(children);
-    return jsHeapAllocated.release();
+    memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::JSHeapUsed, info.usedJSHeapSize);
+    memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::JSHeapUnused, info.totalJSHeapSize - info.usedJSHeapSize);
 }
 
-static PassRefPtr<InspectorMemoryBlock> renderTreeInfo(Page* page)
+static void reportRenderTreeInfo(WTF::MemoryInstrumentationClient& memoryInstrumentationClient, Page* page)
 {
     ArenaSize arenaSize = page->renderTreeSize();
 
-    RefPtr<InspectorMemoryBlock> renderTreeAllocated = InspectorMemoryBlock::create().setName(MemoryBlockName::renderTreeAllocated);
-    renderTreeAllocated->setSize(arenaSize.allocated);
-
-    RefPtr<InspectorMemoryBlocks> children = InspectorMemoryBlocks::create();
-    RefPtr<InspectorMemoryBlock> renderTreeUsed = InspectorMemoryBlock::create().setName(MemoryBlockName::renderTreeUsed);
-    renderTreeUsed->setSize(arenaSize.treeSize);
-    children->addItem(renderTreeUsed);
-
-    renderTreeAllocated->setChildren(children);
-    return renderTreeAllocated.release();
+    memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::RenderTreeUsed, arenaSize.treeSize);
+    memoryInstrumentationClient.countObjectSize(WebCoreMemoryTypes::RenderTreeUnused, arenaSize.allocated - arenaSize.treeSize);
 }
 
 namespace {
 
 class DOMTreesIterator : public NodeWrapperVisitor {
 public:
-    DOMTreesIterator(Page* page, MemoryInstrumentationImpl& memoryInstrumentation)
+    DOMTreesIterator(MemoryInstrumentationImpl& memoryInstrumentation, Page* page)
         : m_page(page)
         , m_memoryInstrumentation(memoryInstrumentation)
     {
@@ -549,7 +489,7 @@ private:
 
 }
 
-static void collectDomTreeInfo(Page* page, MemoryInstrumentationImpl& memoryInstrumentation)
+static void collectDomTreeInfo(MemoryInstrumentationImpl& memoryInstrumentation, Page* page)
 {
     ExternalStringsRoot stringsRoot;
     memoryInstrumentation.addRootObject(stringsRoot);
@@ -557,7 +497,7 @@ static void collectDomTreeInfo(Page* page, MemoryInstrumentationImpl& memoryInst
     ExternalArraysRoot arraysRoot;
     memoryInstrumentation.addRootObject(arraysRoot);
 
-    DOMTreesIterator domTreesIterator(page, memoryInstrumentation);
+    DOMTreesIterator domTreesIterator(memoryInstrumentation, page);
 
     ScriptProfiler::visitNodeWrappers(&domTreesIterator);
 
@@ -584,35 +524,27 @@ static void addPlatformComponentsInfo(PassRefPtr<InspectorMemoryBlocks> children
     }
 }
 
-static PassRefPtr<InspectorMemoryBlock> dumpDOMStorageCache(size_t cacheSize)
-{
-    RefPtr<InspectorMemoryBlock> domStorageCache = InspectorMemoryBlock::create().setName(MemoryBlockName::domStorageCache);
-    domStorageCache->setSize(cacheSize);
-    return domStorageCache;
-}
-
 void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<InspectorMemoryBlock>& processMemory)
 {
-    processMemory = InspectorMemoryBlock::create().setName(MemoryBlockName::processPrivateMemory);
-
-    InspectorDataCounter inspectorData;
-    inspectorData.addComponent(MemoryBlockName::inspectorJSHeapData, ScriptProfiler::profilerSnapshotsSize());
-
-    HashSet<const void*> allocatedObjects;
-    m_inspectorClient->getAllocatedObjects(allocatedObjects);
-    MemoryInstrumentationClientImpl memoryInstrumentationClient(allocatedObjects.isEmpty() ? 0 : &allocatedObjects);
+    MemoryInstrumentationClientImpl memoryInstrumentationClient;
+    m_inspectorClient->getAllocatedObjects(memoryInstrumentationClient.allocatedObjects());
     MemoryInstrumentationImpl memoryInstrumentation(&memoryInstrumentationClient);
 
+    reportJSHeapInfo(memoryInstrumentationClient);
+    reportRenderTreeInfo(memoryInstrumentationClient, m_page);
+    collectDomTreeInfo(memoryInstrumentation, m_page); // FIXME: collect for all pages?
+
     RefPtr<InspectorMemoryBlocks> children = InspectorMemoryBlocks::create();
-    children->addItem(jsHeapInfo());
-    children->addItem(renderTreeInfo(m_page)); // FIXME: collect for all pages?
-    collectDomTreeInfo(m_page, memoryInstrumentation); // FIXME: collect for all pages?
-    children->addItem(dumpDOMStorageCache(m_domStorageAgent->memoryBytesUsedByStorageCache()));
     addPlatformComponentsInfo(children);
+
+    memoryInstrumentation.addRootObject(this);
+    memoryInstrumentation.addRootObject(memoryInstrumentation);
+    memoryInstrumentation.addRootObject(memoryInstrumentationClient);
+
     MemoryUsageStatsGenerator statsGenerator(&memoryInstrumentationClient);
     statsGenerator.dump(children.get());
-    inspectorData.addComponent(MemoryBlockName::inspectorDOMData, memoryInstrumentationClient.selfSize() + memoryInstrumentation.selfSize());
-    children->addItem(inspectorData.dumpStatistics());
+
+    processMemory = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::ProcessPrivateMemory);
     processMemory->setChildren(children);
 
     size_t privateBytes = 0;
@@ -621,11 +553,18 @@ void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<Ins
     processMemory->setSize(privateBytes);
 }
 
-InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent)
+void InspectorMemoryAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Inspector);
+    InspectorBaseAgent<InspectorMemoryAgent>::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_inspectorClient);
+    info.addMember(m_page);
+}
+
+InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page)
     : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents, state)
     , m_inspectorClient(client)
     , m_page(page)
-    , m_domStorageAgent(domStorageAgent)
 {
 }
 
index 31d5bc4..61f1158 100644 (file)
@@ -52,21 +52,22 @@ class InspectorMemoryAgent : public InspectorBaseAgent<InspectorMemoryAgent>, pu
 public:
     typedef Vector<OwnPtr<InspectorBaseAgentInterface> > InspectorAgents;
 
-    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent)
+    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorClient* client, InspectorState* state, Page* page)
     {
-        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, client, state, page, domStorageAgent));
+        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, client, state, page));
     }
     virtual ~InspectorMemoryAgent();
 
     virtual void getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Memory::DOMGroup> >& domGroups, RefPtr<TypeBuilder::Memory::StringStatistics>& strings);
     virtual void getProcessMemoryDistribution(ErrorString*, RefPtr<TypeBuilder::Memory::MemoryBlock>& processMemory);
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
-    InspectorMemoryAgent(InstrumentingAgents*, InspectorClient*, InspectorState*, Page*, InspectorDOMStorageAgent*);
+    InspectorMemoryAgent(InstrumentingAgents*, InspectorClient*, InspectorState*, Page*);
 
     InspectorClient* m_inspectorClient;
     Page* m_page;
-    InspectorDOMStorageAgent* m_domStorageAgent;
 };
 
 } // namespace WebCore
index 64b362e..6c28ed2 100644 (file)
@@ -48,7 +48,9 @@
 #include "ScriptObject.h"
 #include "ScriptProfile.h"
 #include "ScriptProfiler.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "WorkerScriptDebugServer.h"
+#include <wtf/MemoryInstrumentationHashMap.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/text/StringConcatenate.h>
 
@@ -482,6 +484,19 @@ void InspectorProfilerAgent::getHeapObjectId(ErrorString* errorString, const Str
     *heapSnapshotObjectId = String::number(id);
 }
 
+void InspectorProfilerAgent::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorProfilerAgent);
+    InspectorBaseAgent<InspectorProfilerAgent>::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_consoleAgent);
+    info.addMember(m_injectedScriptManager);
+    info.addMember(m_frontend);
+    info.addMember(m_profiles);
+    info.addMember(m_snapshots);
+
+    info.addPrivateBuffer(ScriptProfiler::profilerSnapshotsSize());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
index d548bbf..823b7e6 100644 (file)
@@ -100,6 +100,8 @@ public:
     virtual void getObjectByHeapObjectId(ErrorString*, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result);
     virtual void getHeapObjectId(ErrorString*, const String& objectId, String* heapSnapshotObjectId);
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     InspectorProfilerAgent(InstrumentingAgents*, InspectorConsoleAgent*, InspectorState*, InjectedScriptManager*);
     virtual void startProfiling(const String& title) = 0;
index 14dabea..e93d66f 100644 (file)
 #if ENABLE(INSPECTOR)
 
 #include "MemoryInstrumentationImpl.h"
+
+#include "WebCoreMemoryInstrumentation.h"
 #include <wtf/Assertions.h>
+#include <wtf/MemoryInstrumentationHashMap.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
@@ -71,7 +76,7 @@ void MemoryInstrumentationClientImpl::checkCountedObject(const void* object)
 {
     if (!checkInstrumentedObjects())
         return;
-    if (!m_allocatedObjects->contains(object)) {
+    if (!m_allocatedObjects.contains(object)) {
         ++m_totalObjectsNotInAllocatedSet;
 #if 0
         printf("Found unknown object referenced by pointer: %p\n", object);
@@ -80,6 +85,14 @@ void MemoryInstrumentationClientImpl::checkCountedObject(const void* object)
     }
 }
 
+void MemoryInstrumentationClientImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorMemoryAgent);
+    info.addMember(m_totalSizes);
+    info.addMember(m_visitedObjects);
+    info.addMember(m_allocatedObjects);
+}
+
 void MemoryInstrumentationImpl::processDeferredInstrumentedPointers()
 {
     while (!m_deferredInstrumentedPointers.isEmpty()) {
@@ -94,11 +107,13 @@ void MemoryInstrumentationImpl::deferInstrumentedPointer(PassOwnPtr<Instrumented
     m_deferredInstrumentedPointers.append(pointer);
 }
 
-size_t MemoryInstrumentationImpl::selfSize() const
+void MemoryInstrumentationImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    return calculateContainerSize(m_deferredInstrumentedPointers);
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::InspectorMemoryAgent);
+    info.addMember(m_deferredInstrumentedPointers);
 }
 
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 40e25e7..8af8d60 100644 (file)
@@ -48,9 +48,8 @@ typedef HashMap<String, size_t> TypeNameToSizeMap;
 
 class MemoryInstrumentationClientImpl : public WTF::MemoryInstrumentationClient {
 public:
-    explicit MemoryInstrumentationClientImpl(VisitedObjects* allocatedObjects)
-        : m_allocatedObjects(allocatedObjects)
-        , m_totalCountedObjects(0)
+    MemoryInstrumentationClientImpl()
+        : m_totalCountedObjects(0)
         , m_totalObjectsNotInAllocatedSet(0)
     { }
 
@@ -68,15 +67,10 @@ public:
         return size;
     }
 
-    size_t selfSize() const
-    {
-        return m_visitedObjects.capacity() * sizeof(VisitedObjects::ValueType) +
-            m_totalSizes.capacity() * sizeof(TypeToSizeMap::ValueType);
-    }
-
     TypeNameToSizeMap sizesMap() const;
+    VisitedObjects& allocatedObjects() { return m_allocatedObjects; }
 
-    bool checkInstrumentedObjects() const { return m_allocatedObjects; }
+    bool checkInstrumentedObjects() const { return !m_allocatedObjects.isEmpty(); }
     size_t visitedObjects() const { return m_visitedObjects.size(); }
     size_t totalCountedObjects() const { return m_totalCountedObjects; }
     size_t totalObjectsNotInAllocatedSet() const { return m_totalObjectsNotInAllocatedSet; }
@@ -85,11 +79,13 @@ public:
     virtual bool visited(const void*) OVERRIDE;
     virtual void checkCountedObject(const void*) OVERRIDE;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     typedef HashMap<MemoryObjectType, size_t> TypeToSizeMap;
     TypeToSizeMap m_totalSizes;
     VisitedObjects m_visitedObjects;
-    const VisitedObjects* m_allocatedObjects;
+    VisitedObjects m_allocatedObjects;
     size_t m_totalCountedObjects;
     size_t m_totalObjectsNotInAllocatedSet;
 };
@@ -103,6 +99,8 @@ public:
 
     size_t selfSize() const;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) OVERRIDE;
     virtual void processDeferredInstrumentedPointers() OVERRIDE;
index 578330f..1c0cb67 100644 (file)
@@ -219,17 +219,17 @@ WebInspector.MemoryBlockViewProperties._initialize = function()
     addBlock("hsl(  0,  0%,  80%)", "OwnersTypePlaceholder", "OwnersTypePlaceholder");
     addBlock("hsl(  0,  0%,  80%)", "Other", "Other");
     addBlock("hsl(300, 30%,  80%)", "Page", "Page's structures");
-    addBlock("hsl( 90, 60%,  80%)", "JSHeapAllocated", "JavaScript heap");
-    addBlock("hsl( 90, 80%,  80%)", "JSHeapUsed", "Used JavaScript heap");
+    addBlock("hsl( 90, 60%,  80%)", "JSHeap", "JavaScript heap");
+    addBlock("hsl( 90, 80%,  80%)", "JSHeap.Used", "Used JavaScript heap");
     addBlock("hsl( 90, 30%,  80%)", "JSExternalResources", "JavaScript external resources");
     addBlock("hsl( 90, 40%,  80%)", "JSExternalArrays", "JavaScript external arrays");
     addBlock("hsl( 90, 50%,  80%)", "JSExternalStrings", "JavaScript external strings");
-    addBlock("hsl(210, 60%,  80%)", "InspectorData", "Inspector data");
+    addBlock("hsl(210, 60%,  80%)", "WebInspector", "Inspector data");
     addBlock("hsl( 30, 60%,  80%)", "MemoryCache", "Memory cache resources");
     addBlock("hsl( 40, 60%,  80%)", "GlyphCache", "Glyph cache resources");
     addBlock("hsl( 35, 60%,  80%)", "DOMStorageCache", "DOM storage cache");
-    addBlock("hsl( 60, 60%,  80%)", "RenderTreeAllocated", "Render tree");
-    addBlock("hsl( 60, 60%,  80%)", "RenderTreeUsed", "Render tree used");
+    addBlock("hsl( 60, 60%,  80%)", "RenderTree", "Render tree");
+    addBlock("hsl( 60, 60%,  80%)", "RenderTree.Used", "Render tree used");
 }
 
 WebInspector.MemoryBlockViewProperties._forMemoryBlock = function(memoryBlock)
@@ -474,9 +474,13 @@ WebInspector.NativeMemoryBarChart.prototype = {
             }
             var unusedSize = 0;
             if (!!child.children) {
-                unusedSize = child.size;
-                for (var j = 0; j < child.children.length; ++j)
-                    unusedSize -= child.children[j].size;
+                var unusedName = name + ".Unused";
+                for (var j = 0; j < child.children.length; ++j) {
+                    if (child.children[j].name === unusedName) {
+                        unusedSize = child.children[j].size;
+                        break;
+                    }
+                }
             }
             var unusedLength = unusedSize * barLengthSizeRatio;
             var barLength = child.size * barLengthSizeRatio;
index ecb0a2f..3df7586 100644 (file)
@@ -72,6 +72,7 @@
 #include "StyleResolver.h"
 #include "TextResourceDecoder.h"
 #include "VoidCallback.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "Widget.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCountedLeakCounter.h>
@@ -1266,6 +1267,49 @@ void Page::resetSeenPlugins()
     m_seenPlugins.clear();
 }
 
+void Page::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Page);
+    info.addMember(m_chrome);
+    info.addMember(m_dragCaretController);
+
+#if ENABLE(DRAG_SUPPORT)
+    info.addMember(m_dragController);
+#endif
+    info.addMember(m_focusController);
+#if ENABLE(CONTEXT_MENUS)
+    info.addMember(m_contextMenuController);
+#endif
+#if ENABLE(INSPECTOR)
+    info.addMember(m_inspectorController);
+#endif
+#if ENABLE(POINTER_LOCK)
+    info.addMember(m_pointerLockController);
+#endif
+    info.addMember(m_scrollingCoordinator);
+    info.addMember(m_settings);
+    info.addMember(m_progress);
+    info.addMember(m_backForwardController);
+    info.addMember(m_mainFrame);
+    info.addMember(m_pluginData);
+    info.addMember(m_theme);
+    info.addMember(m_editorClient);
+    info.addMember(m_featureObserver);
+    info.addMember(m_groupName);
+    info.addMember(m_pagination);
+    info.addMember(m_userStyleSheetPath);
+    info.addMember(m_userStyleSheet);
+    info.addMember(m_singlePageGroup);
+    info.addMember(m_group);
+    info.addWeakPointer(m_debugger);
+    info.addMember(m_sessionStorage);
+    info.addMember(m_relevantUnpaintedRenderObjects);
+    info.addMember(m_relevantPaintedRegion);
+    info.addMember(m_relevantUnpaintedRegion);
+    info.addMember(m_alternativeTextClient);
+    info.addMember(m_seenPlugins);
+}
+
 Page::PageClients::PageClients()
     : alternativeTextClient(0)
     , chromeClient(0)
index de68dab..76d9ac7 100644 (file)
@@ -352,6 +352,8 @@ namespace WebCore {
         void sawPlugin(const String& serviceType);
         void resetSeenPlugins();
 
+        void reportMemoryUsage(MemoryObjectInfo*) const;
+
     private:
         void initGroup();