Changeset 121952 in webkit
- Timestamp:
- Jul 6, 2012 4:25:28 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121951 r121952 1 2012-07-06 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: add memory reporting routine to Document 4 https://bugs.webkit.org/show_bug.cgi?id=90668 5 6 Reviewed by Pavel Feldman. 7 8 Added methods for reporting HashSet, ListHashSet and Vector memory 9 footprint. Made Document report its size along with its internal 10 collections sizes. 11 12 * dom/Document.cpp: 13 (WebCore::Document::reportMemoryUsage): 14 (WebCore): 15 * dom/Document.h: 16 (Document): 17 * dom/MemoryInstrumentation.h: 18 (MemoryInstrumentation): 19 (MemoryObjectInfo): 20 (WebCore::MemoryObjectInfo::reportHashMap): 21 (WebCore::MemoryObjectInfo::reportHashSet): 22 (WebCore::MemoryObjectInfo::reportListHashSet): 23 (WebCore::MemoryObjectInfo::reportVector): 24 (WebCore::MemoryObjectInfo::memoryInstrumentation): 25 (WebCore::MemoryInstrumentation::reportHashMap): 26 (WebCore): 27 (WebCore::MemoryInstrumentation::reportHashSet): 28 (WebCore::MemoryInstrumentation::reportListHashSet): 29 (WebCore::MemoryInstrumentation::reportVector): 30 * inspector/InspectorMemoryAgent.cpp: 31 (WebCore): 32 1 33 2012-07-06 Gabor Rapcsanyi <rgabor@webkit.org> 2 34 -
trunk/Source/WebCore/dom/Document.cpp
r121866 r121952 110 110 #include "MediaQueryList.h" 111 111 #include "MediaQueryMatcher.h" 112 #include "MemoryInstrumentation.h" 112 113 #include "MouseEventWithHitTestResults.h" 113 114 #include "NameNodeList.h" … … 5995 5996 } 5996 5997 5998 void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 5999 { 6000 memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::DOM); 6001 ContainerNode::reportMemoryUsage(memoryObjectInfo); 6002 memoryObjectInfo->reportVector(m_customFonts); 6003 memoryObjectInfo->reportString(m_documentURI); 6004 memoryObjectInfo->reportString(m_baseTarget); 6005 if (m_pageGroupUserSheets) 6006 memoryObjectInfo->reportVector(*m_pageGroupUserSheets.get()); 6007 if (m_userSheets) 6008 memoryObjectInfo->reportVector(*m_userSheets.get()); 6009 memoryObjectInfo->reportHashSet(m_nodeIterators); 6010 memoryObjectInfo->reportHashSet(m_ranges); 6011 memoryObjectInfo->reportListHashSet(m_styleSheetCandidateNodes); 6012 memoryObjectInfo->reportString(m_preferredStylesheetSet); 6013 memoryObjectInfo->reportString(m_selectedStylesheetSet); 6014 memoryObjectInfo->reportString(m_title.string()); 6015 memoryObjectInfo->reportString(m_rawTitle.string()); 6016 memoryObjectInfo->reportString(m_xmlEncoding); 6017 memoryObjectInfo->reportString(m_xmlVersion); 6018 memoryObjectInfo->reportString(m_contentLanguage); 6019 memoryObjectInfo->reportHashMap(m_documentNamedItemCollections); 6020 memoryObjectInfo->reportHashMap(m_windowNamedItemCollections); 6021 #if ENABLE(DASHBOARD_SUPPORT) 6022 memoryObjectInfo->reportVector(m_dashboardRegions); 6023 #endif 6024 memoryObjectInfo->reportHashMap(m_cssCanvasElements); 6025 memoryObjectInfo->reportVector(m_iconURLs); 6026 memoryObjectInfo->reportHashSet(m_documentSuspensionCallbackElements); 6027 memoryObjectInfo->reportHashSet(m_mediaVolumeCallbackElements); 6028 memoryObjectInfo->reportHashSet(m_privateBrowsingStateChangedElements); 6029 memoryObjectInfo->reportHashMap(m_elementsByAccessKey); 6030 memoryObjectInfo->reportHashSet(m_mediaCanStartListeners); 6031 memoryObjectInfo->reportVector(m_pendingTasks); 6032 } 6033 5997 6034 #if ENABLE(UNDO_MANAGER) 5998 6035 PassRefPtr<UndoManager> Document::undoManager() -
trunk/Source/WebCore/dom/Document.h
r121866 r121952 1144 1144 ContextFeatures* contextFeatures() { return m_contextFeatures.get(); } 1145 1145 1146 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; 1147 1146 1148 protected: 1147 1149 Document(Frame*, const KURL&, bool isXHTML, bool isHTML); -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r121677 r121952 62 62 countObjectSize(objectType, sizeof(T)); 63 63 } 64 template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType); 64 template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType, bool contentOnly = false); 65 template <typename HashSetType> void reportHashSet(const HashSetType&, ObjectType, bool contentOnly = false); 66 template <typename ListHashSetType> void reportListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false); 67 template <typename VectorType> void reportVector(const VectorType&, ObjectType, bool contentOnly = false); 65 68 66 69 protected: … … 130 133 } 131 134 135 template <typename HashMapType> 136 void reportHashMap(const HashMapType& map) 137 { 138 m_memoryInstrumentation->reportHashMap(map, objectType(), true); 139 } 140 141 template <typename HashSetType> 142 void reportHashSet(const HashSetType& set) 143 { 144 m_memoryInstrumentation->reportHashSet(set, objectType(), true); 145 } 146 147 template <typename ListHashSetType> 148 void reportListHashSet(const ListHashSetType& set) 149 { 150 m_memoryInstrumentation->reportListHashSet(set, objectType(), true); 151 } 152 153 template <typename VectorType> 154 void reportVector(const VectorType& vector) 155 { 156 m_memoryInstrumentation->reportVector(vector, objectType(), true); 157 } 158 132 159 void reportString(const String& string) 133 160 { … … 137 164 MemoryInstrumentation::ObjectType objectType() const { return m_objectType; } 138 165 size_t objectSize() const { return m_objectSize; } 166 167 MemoryInstrumentation* memoryInstrumentation() { return m_memoryInstrumentation; } 139 168 140 169 private: … … 162 191 163 192 template<typename HashMapType> 164 void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType) 165 { 166 size_t size = sizeof(HashMapType) + hashMap.capacity() * sizeof(typename HashMapType::ValueType); 193 void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly) 194 { 195 size_t size = (contentOnly ? 0 : sizeof(HashMapType)) + hashMap.capacity() * sizeof(typename HashMapType::ValueType); 196 countObjectSize(objectType, size); 197 } 198 199 template<typename HashSetType> 200 void MemoryInstrumentation::reportHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly) 201 { 202 if (visited(&hashSet)) 203 return; 204 size_t size = (contentOnly ? 0 : sizeof(HashSetType)) + hashSet.capacity() * sizeof(typename HashSetType::ValueType); 205 countObjectSize(objectType, size); 206 } 207 208 template<typename ListHashSetType> 209 void MemoryInstrumentation::reportListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly) 210 { 211 if (visited(&hashSet)) 212 return; 213 size_t size = (contentOnly ? 0 : sizeof(ListHashSetType)) + hashSet.capacity() * sizeof(void*) + hashSet.size() * (sizeof(typename ListHashSetType::ValueType) + 2 * sizeof(void*)); 214 countObjectSize(objectType, size); 215 } 216 217 template <typename VectorType> 218 void MemoryInstrumentation::reportVector(const VectorType& vector, ObjectType objectType, bool contentOnly) 219 { 220 if (visited(vector.data())) 221 return; 222 size_t size = (contentOnly ? 0 : sizeof(VectorType)) + vector.capacity() * sizeof(typename VectorType::ValueType); 167 223 countObjectSize(objectType, size); 168 224 } -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r121677 r121952 472 472 virtual void reportString(ObjectType objectType, const String& string) 473 473 { 474 if ( visited(string.impl()))474 if (string.isNull() || visited(string.impl())) 475 475 return; 476 476 countObjectSize(objectType, stringSize(string.impl()));
Note: See TracChangeset
for help on using the changeset viewer.