vm: release memory used by sampler vectors

db4
Joe Groff 2011-10-30 18:41:14 -07:00
parent 9f6f36fdec
commit 1089816b21
2 changed files with 12 additions and 1 deletions

View File

@ -61,11 +61,21 @@ void factor_vm::set_sampling_profiler(bool sampling_p)
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<code_block*> sample_callstack_graveyard;
samples.swap(sample_graveyard);
sample_callstacks.swap(sample_callstack_graveyard);
}
void factor_vm::start_sampling_profiler()
{
safepoint_sample_count = 0;
safepoint_gc_sample_count = 0;
samples.clear();
clear_samples();
samples.reserve(10*FACTOR_PROFILE_SAMPLES_PER_SECOND);
sample_callstacks.reserve(100*FACTOR_PROFILE_SAMPLES_PER_SECOND);
sampling_profiler_p = true;

View File

@ -191,6 +191,7 @@ struct factor_vm
void primitive_counting_profiler();
/* Sampling profiler */
void clear_samples();
void record_sample();
void record_callstack_sample(cell *begin, cell *end);
void start_sampling_profiler();