diff --git a/basis/tools/profiler/sampling/sampling-tests.factor b/basis/tools/profiler/sampling/sampling-tests.factor index 91fe547c35..51a948b56f 100644 --- a/basis/tools/profiler/sampling/sampling-tests.factor +++ b/basis/tools/profiler/sampling/sampling-tests.factor @@ -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 diff --git a/vm/sampling_profiler.cpp b/vm/sampling_profiler.cpp index dc6def6ed2..90152f5db6 100644 --- a/vm/sampling_profiler.cpp +++ b/vm/sampling_profiler.cpp @@ -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);