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

Side by Side Diff: src/heap.cc

Issue 261037: Add an API to V8 to get simple heap statistics. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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 | « src/heap.h ('k') | src/spaces.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 return new_space_.Capacity() + 121 return new_space_.Capacity() +
122 old_pointer_space_->Capacity() + 122 old_pointer_space_->Capacity() +
123 old_data_space_->Capacity() + 123 old_data_space_->Capacity() +
124 code_space_->Capacity() + 124 code_space_->Capacity() +
125 map_space_->Capacity() + 125 map_space_->Capacity() +
126 cell_space_->Capacity(); 126 cell_space_->Capacity();
127 } 127 }
128 128
129 129
130 int Heap::CommittedMemory() {
131 if (!HasBeenSetup()) return 0;
132
133 return new_space_.CommittedMemory() +
134 old_pointer_space_->CommittedMemory() +
135 old_data_space_->CommittedMemory() +
136 code_space_->CommittedMemory() +
137 map_space_->CommittedMemory() +
138 cell_space_->CommittedMemory() +
139 lo_space_->Size();
140 }
141
142
130 int Heap::Available() { 143 int Heap::Available() {
131 if (!HasBeenSetup()) return 0; 144 if (!HasBeenSetup()) return 0;
132 145
133 return new_space_.Available() + 146 return new_space_.Available() +
134 old_pointer_space_->Available() + 147 old_pointer_space_->Available() +
135 old_data_space_->Available() + 148 old_data_space_->Available() +
136 code_space_->Available() + 149 code_space_->Available() +
137 map_space_->Available() + 150 map_space_->Available() +
138 cell_space_->Available(); 151 cell_space_->Available();
139 } 152 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 new_space_.ClearHistograms(); 228 new_space_.ClearHistograms();
216 } 229 }
217 #endif 230 #endif
218 } 231 }
219 232
220 233
221 #if defined(ENABLE_LOGGING_AND_PROFILING) 234 #if defined(ENABLE_LOGGING_AND_PROFILING)
222 void Heap::PrintShortHeapStatistics() { 235 void Heap::PrintShortHeapStatistics() {
223 if (!FLAG_trace_gc_verbose) return; 236 if (!FLAG_trace_gc_verbose) return;
224 PrintF("Memory allocator, used: %8d, available: %8d\n", 237 PrintF("Memory allocator, used: %8d, available: %8d\n",
225 MemoryAllocator::Size(), MemoryAllocator::Available()); 238 MemoryAllocator::Size(),
239 MemoryAllocator::Available());
226 PrintF("New space, used: %8d, available: %8d\n", 240 PrintF("New space, used: %8d, available: %8d\n",
227 Heap::new_space_.Size(), new_space_.Available()); 241 Heap::new_space_.Size(),
228 PrintF("Old pointers, used: %8d, available: %8d\n", 242 new_space_.Available());
229 old_pointer_space_->Size(), old_pointer_space_->Available()); 243 PrintF("Old pointers, used: %8d, available: %8d, waste: %8d\n",
230 PrintF("Old data space, used: %8d, available: %8d\n", 244 old_pointer_space_->Size(),
231 old_data_space_->Size(), old_data_space_->Available()); 245 old_pointer_space_->Available(),
232 PrintF("Code space, used: %8d, available: %8d\n", 246 old_pointer_space_->Waste());
233 code_space_->Size(), code_space_->Available()); 247 PrintF("Old data space, used: %8d, available: %8d, waste: %8d\n",
234 PrintF("Map space, used: %8d, available: %8d\n", 248 old_data_space_->Size(),
235 map_space_->Size(), map_space_->Available()); 249 old_data_space_->Available(),
250 old_data_space_->Waste());
251 PrintF("Code space, used: %8d, available: %8d, waste: %8d\n",
252 code_space_->Size(),
253 code_space_->Available(),
254 code_space_->Waste());
255 PrintF("Map space, used: %8d, available: %8d, waste: %8d\n",
256 map_space_->Size(),
257 map_space_->Available(),
258 map_space_->Waste());
259 PrintF("Cell space, used: %8d, available: %8d, waste: %8d\n",
260 cell_space_->Size(),
261 cell_space_->Available(),
262 cell_space_->Waste());
236 PrintF("Large object space, used: %8d, avaialble: %8d\n", 263 PrintF("Large object space, used: %8d, avaialble: %8d\n",
237 lo_space_->Size(), lo_space_->Available()); 264 lo_space_->Size(),
265 lo_space_->Available());
238 } 266 }
239 #endif 267 #endif
240 268
241 269
242 // TODO(1238405): Combine the infrastructure for --heap-stats and 270 // TODO(1238405): Combine the infrastructure for --heap-stats and
243 // --log-gc to avoid the complicated preprocessor and flag testing. 271 // --log-gc to avoid the complicated preprocessor and flag testing.
244 void Heap::ReportStatisticsAfterGC() { 272 void Heap::ReportStatisticsAfterGC() {
245 // Similar to the before GC, we use some complicated logic to ensure that 273 // Similar to the before GC, we use some complicated logic to ensure that
246 // NewSpace statistics are logged exactly once when --log-gc is turned on. 274 // NewSpace statistics are logged exactly once when --log-gc is turned on.
247 #if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING) 275 #if defined(DEBUG) && defined(ENABLE_LOGGING_AND_PROFILING)
(...skipping 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 for (int i = 0; i < kNumberOfCaches; i++) { 3915 for (int i = 0; i < kNumberOfCaches; i++) {
3888 if (caches_[i] != NULL) { 3916 if (caches_[i] != NULL) {
3889 delete caches_[i]; 3917 delete caches_[i];
3890 caches_[i] = NULL; 3918 caches_[i] = NULL;
3891 } 3919 }
3892 } 3920 }
3893 } 3921 }
3894 3922
3895 3923
3896 } } // namespace v8::internal 3924 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698