Chromium Code Reviews| Index: runtime/vm/profiler.cc |
| diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc |
| index da856e2844ba9f3dd8efcd6f961407a9533460b5..8d37ebc90edd78a4403394e3b5fabfcd9d033e42 100644 |
| --- a/runtime/vm/profiler.cc |
| +++ b/runtime/vm/profiler.cc |
| @@ -129,16 +129,29 @@ uword* Sample::GetPCArray() const { |
| SampleBuffer::SampleBuffer(intptr_t capacity) { |
| ASSERT(Sample::instance_size() > 0); |
| - samples_ = |
| - reinterpret_cast<Sample*>(calloc(capacity, Sample::instance_size())); |
| + |
| + intptr_t size = Utils::RoundUp(capacity * Sample::instance_size(), |
|
zra
2017/06/23 04:43:41
const
rmacnak
2017/06/23 21:05:52
Done.
|
| + VirtualMemory::PageSize()); |
| + const bool kNotExecutable = false; |
| + memory_ = VirtualMemory::Reserve(size); |
| + if ((memory_ == NULL) || !memory_->Commit(kNotExecutable, "dart-profiler")) { |
| + OUT_OF_MEMORY(); |
| + } |
| + |
| + samples_ = reinterpret_cast<Sample*>(memory_->address()); |
| + capacity_ = capacity; |
| + cursor_ = 0; |
| + |
| if (FLAG_trace_profiler) { |
| OS::Print("Profiler holds %" Pd " samples\n", capacity); |
| OS::Print("Profiler sample is %" Pd " bytes\n", Sample::instance_size()); |
| - OS::Print("Profiler memory usage = %" Pd " bytes\n", |
| - capacity * Sample::instance_size()); |
| + OS::Print("Profiler memory usage = %" Pd " bytes\n", size); |
| } |
| - capacity_ = capacity; |
| - cursor_ = 0; |
| +} |
| + |
| + |
| +SampleBuffer::~SampleBuffer() { |
| + delete memory_; |
| } |