Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: src/profile-generator.cc

Issue 9307050: Memory leak at NativeObjectsExplorer::FindOrAddGroupInfo (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 for (HashMap::Entry* p = objects_by_info_.Start(); 2713 for (HashMap::Entry* p = objects_by_info_.Start();
2714 p != NULL; 2714 p != NULL;
2715 p = objects_by_info_.Next(p)) { 2715 p = objects_by_info_.Next(p)) {
2716 v8::RetainedObjectInfo* info = 2716 v8::RetainedObjectInfo* info =
2717 reinterpret_cast<v8::RetainedObjectInfo*>(p->key); 2717 reinterpret_cast<v8::RetainedObjectInfo*>(p->key);
2718 info->Dispose(); 2718 info->Dispose();
2719 List<HeapObject*>* objects = 2719 List<HeapObject*>* objects =
2720 reinterpret_cast<List<HeapObject*>* >(p->value); 2720 reinterpret_cast<List<HeapObject*>* >(p->value);
2721 delete objects; 2721 delete objects;
2722 } 2722 }
2723 for (HashMap::Entry* p = native_groups_.Start();
2724 p != NULL;
2725 p = native_groups_.Next(p)) {
2726 v8::RetainedObjectInfo* info =
2727 reinterpret_cast<v8::RetainedObjectInfo*>(p->value);
2728 info->Dispose();
2729 }
2723 } 2730 }
2724 2731
2725 2732
2726 HeapEntry* NativeObjectsExplorer::AllocateEntry( 2733 HeapEntry* NativeObjectsExplorer::AllocateEntry(
2727 HeapThing ptr, int children_count, int retainers_count) { 2734 HeapThing ptr, int children_count, int retainers_count) {
2728 v8::RetainedObjectInfo* info = 2735 v8::RetainedObjectInfo* info =
2729 reinterpret_cast<v8::RetainedObjectInfo*>(ptr); 2736 reinterpret_cast<v8::RetainedObjectInfo*>(ptr);
2730 intptr_t elements = info->GetElementCount(); 2737 intptr_t elements = info->GetElementCount();
2731 intptr_t size = info->GetSizeInBytes(); 2738 intptr_t size = info->GetSizeInBytes();
2732 return snapshot_->AddEntry( 2739 return snapshot_->AddEntry(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2809 SetRootNativeRootsReference(); 2816 SetRootNativeRootsReference();
2810 filler_ = NULL; 2817 filler_ = NULL;
2811 return true; 2818 return true;
2812 } 2819 }
2813 2820
2814 2821
2815 class NativeGroupRetainedObjectInfo : public v8::RetainedObjectInfo { 2822 class NativeGroupRetainedObjectInfo : public v8::RetainedObjectInfo {
2816 public: 2823 public:
2817 explicit NativeGroupRetainedObjectInfo(const char* label) 2824 explicit NativeGroupRetainedObjectInfo(const char* label)
2818 : disposed_(false), 2825 : disposed_(false),
2819 hash_(reinterpret_cast<intptr_t>(label)), 2826 hash_(reinterpret_cast<intptr_t>(label)),
mnaganov (inactive) 2012/02/02 12:00:46 BTW, you should use ComputeIntegerHash here for be
2820 label_(label) { 2827 label_(label) {
2821 } 2828 }
2822 2829
2823 virtual ~NativeGroupRetainedObjectInfo() {} 2830 virtual ~NativeGroupRetainedObjectInfo() {}
2824 virtual void Dispose() { 2831 virtual void Dispose() {
2825 CHECK(!disposed_); 2832 CHECK(!disposed_);
2826 disposed_ = true; 2833 disposed_ = true;
2834 delete this;
2827 } 2835 }
2828 virtual bool IsEquivalent(RetainedObjectInfo* other) { 2836 virtual bool IsEquivalent(RetainedObjectInfo* other) {
2829 return hash_ == other->GetHash() && !strcmp(label_, other->GetLabel()); 2837 return hash_ == other->GetHash() && !strcmp(label_, other->GetLabel());
2830 } 2838 }
2831 virtual intptr_t GetHash() { return hash_; } 2839 virtual intptr_t GetHash() { return hash_; }
2832 virtual const char* GetLabel() { return label_; } 2840 virtual const char* GetLabel() { return label_; }
2833 2841
2834 private: 2842 private:
2835 bool disposed_; 2843 bool disposed_;
2836 intptr_t hash_; 2844 intptr_t hash_;
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 3667
3660 3668
3661 void HeapSnapshotJSONSerializer::SortHashMap( 3669 void HeapSnapshotJSONSerializer::SortHashMap(
3662 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3670 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3663 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3671 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3664 sorted_entries->Add(p); 3672 sorted_entries->Add(p);
3665 sorted_entries->Sort(SortUsingEntryValue); 3673 sorted_entries->Sort(SortUsingEntryValue);
3666 } 3674 }
3667 3675
3668 } } // namespace v8::internal 3676 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698