Chromium Code Reviews| Index: src/profile-generator.cc |
| diff --git a/src/profile-generator.cc b/src/profile-generator.cc |
| index 02c67f4ea6656d057610a1b549edf01e174fd672..e8f3d4ff0598c394ae5db918b3a2327aac670a18 100644 |
| --- a/src/profile-generator.cc |
| +++ b/src/profile-generator.cc |
| @@ -169,6 +169,15 @@ const char* StringsStorage::GetName(int index) { |
| } |
| +size_t StringsStorage::GetUsedMemorySize() const { |
| + size_t size = sizeof(*this); |
| + size += sizeof(HashMap::Entry) * names_.capacity(); |
| + for (HashMap::Entry* p = names_.Start(); p != NULL; p = names_.Next(p)) { |
| + size += strlen(reinterpret_cast<const char*>(p->value)) + 1; |
| + } |
| + return size; |
| +} |
| + |
| const char* const CodeEntry::kEmptyNamePrefix = ""; |
| @@ -1243,12 +1252,13 @@ void HeapSnapshot::Print(int max_depth) { |
| template<typename T, class P> |
| static size_t GetMemoryUsedByList(const List<T, P>& list) { |
| - return list.capacity() * sizeof(T); |
| + return list.length() * sizeof(T) + sizeof(list); |
| } |
| size_t HeapSnapshot::RawSnapshotSize() const { |
| return |
| + sizeof(*this) + |
| GetMemoryUsedByList(entries_) + |
| GetMemoryUsedByList(edges_) + |
| GetMemoryUsedByList(children_) + |
| @@ -1446,6 +1456,15 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { |
| } |
| +size_t HeapObjectsMap::GetUsedMemorySize() const { |
| + return |
| + sizeof(*this) + |
| + sizeof(HashMap::Entry) * entries_map_.capacity() + |
| + GetMemoryUsedByList(entries_) + |
| + GetMemoryUsedByList(time_intervals_); |
| +} |
| + |
| + |
| HeapSnapshotsCollection::HeapSnapshotsCollection() |
| : is_tracking_objects_(false), |
| snapshots_uids_(HeapSnapshotsMatch), |
| @@ -1525,6 +1544,19 @@ Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById( |
| } |
| +size_t HeapSnapshotsCollection::GetUsedMemorySize() const { |
| + size_t size = sizeof(*this); |
|
mnaganov (inactive)
2012/06/11 09:47:19
I think we need to mention in declarations of all
loislo
2012/06/11 09:59:20
2 alexeif: please provide a run-time assert or eve
mnaganov (inactive)
2012/06/11 10:01:55
Compile-time assert is preferred.
alf
2012/06/12 17:51:28
Done.
|
| + size += names_.GetUsedMemorySize(); |
| + size += ids_.GetUsedMemorySize(); |
| + size += sizeof(HashMap::Entry) * snapshots_uids_.capacity(); |
| + size += GetMemoryUsedByList(snapshots_); |
| + for (int i = 0; i < snapshots_.length(); ++i) { |
| + size += snapshots_[i]->RawSnapshotSize(); |
| + } |
| + return size; |
| +} |
| + |
| + |
| HeapEntriesMap::HeapEntriesMap() |
| : entries_(HeapThingsMatch) { |
| } |