VM: when starting the sampling profiler, the data needs to be cleared

locals-and-roots
Björn Lindqvist 2016-05-06 19:56:13 +02:00
parent 2d7d61e2e2
commit 7f8d5cbef4
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,6 @@
USING: byte-arrays calendar kernel math memory namespaces
random threads tools.profiler.sampling
tools.profiler.sampling.private tools.test sequences ;
USING: byte-arrays calendar kernel math memory namespaces parser
random sequences threads tools.profiler.sampling
tools.profiler.sampling.private tools.test ;
IN: tools.profiler.sampling.tests
! Make sure the profiler doesn't blow up the VM
@ -16,3 +16,11 @@ TUPLE: boom ;
f raw-profile-data set-global
gc
{ t 0 } [
! Seed the samples data
[ "resource:basis/tools/memory/memory.factor" run-file ] profile
(get-samples) length 0 >
! Should clear it
[ ] profile (get-samples) length
] unit-test

View File

@ -71,8 +71,11 @@ void factor_vm::start_sampling_profiler(fixnum rate) {
samples_per_second = rate;
safepoint.sample_counts.clear();
// Release the memory consumed by colleting samples.
samples.clear();
samples.shrink_to_fit();
sample_callstacks.clear();
sample_callstacks.shrink_to_fit();
samples.reserve(10 * rate);
sample_callstacks.reserve(100 * rate);
atomic::store(&sampling_profiler_p, true);