VM: The C++11 method shrink_to_fit() can be used to release memory
parent
5826394573
commit
9824be8714
|
@ -67,19 +67,12 @@ void factor_vm::set_sampling_profiler(fixnum rate) {
|
||||||
end_sampling_profiler();
|
end_sampling_profiler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::clear_samples() {
|
|
||||||
// Swapping into temporaries releases the vector's allocated storage,
|
|
||||||
// whereas clear() would leave the allocation as-is
|
|
||||||
std::vector<profiling_sample> sample_graveyard;
|
|
||||||
std::vector<cell> sample_callstack_graveyard;
|
|
||||||
samples.swap(sample_graveyard);
|
|
||||||
sample_callstacks.swap(sample_callstack_graveyard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void factor_vm::start_sampling_profiler(fixnum rate) {
|
void factor_vm::start_sampling_profiler(fixnum rate) {
|
||||||
samples_per_second = rate;
|
samples_per_second = rate;
|
||||||
safepoint.sample_counts.clear();
|
safepoint.sample_counts.clear();
|
||||||
clear_samples();
|
// Release the memory consumed by colleting samples.
|
||||||
|
samples.shrink_to_fit();
|
||||||
|
sample_callstacks.shrink_to_fit();
|
||||||
samples.reserve(10 * rate);
|
samples.reserve(10 * rate);
|
||||||
sample_callstacks.reserve(100 * rate);
|
sample_callstacks.reserve(100 * rate);
|
||||||
atomic::store(&sampling_profiler_p, true);
|
atomic::store(&sampling_profiler_p, true);
|
||||||
|
|
|
@ -190,7 +190,6 @@ struct factor_vm {
|
||||||
void primitive_become();
|
void primitive_become();
|
||||||
|
|
||||||
// sampling_profiler
|
// sampling_profiler
|
||||||
void clear_samples();
|
|
||||||
void record_sample(bool prolog_p);
|
void record_sample(bool prolog_p);
|
||||||
void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
|
void record_callstack_sample(cell* begin, cell* end, bool prolog_p);
|
||||||
void start_sampling_profiler(fixnum rate);
|
void start_sampling_profiler(fixnum rate);
|
||||||
|
|
Loading…
Reference in New Issue