使用链接列表删除数组分配。 indumentimplementation会在每个呼叫到`traververe`的阵列。这种拼凑了一个链接的列表,以便任何有兴趣对`travel`保持发布的块只能保持路径节点(at'父母的trail nodepoints)。这方法从11173668减少分配到2940.那是我使用的测试:````rubyrequire' stackprof'需要' allocation_tracer'要求' rubygems / test_case'要求' rubygems / ext'要求' rubygems /规格'要求'基准和#39;类testgemspecification< gem :: testcase def test_runtime make_gems do stackprof.run(模式::墙,out:' /tmp/out.dump& #39;)do assert_raises(loadError){要求' no_such_file_foo' }结束结束ode test_alone make_gems do tms = benchmark.measure {assert_raises(loaderror){reserv' no_such_file_foo' p tms.total assert_operator tms.total,:< =,10个结束def test_memory make_gems do objectspace :: allocationtracer.setup(%i {path行类型})r = objectspace :: allocationtracer.trace do assert_raises(loaderror ){要求' no_such_file_foo' }结束r.sort_by {| k,v | V.First}。家伙Do | K,V | p k => v end p hash_alloc:objectspace :: allocationtracer.allocated_count_table [:t_hash] p array_alloc:objectspace :: allocationtracer.allocated_count_table [:t_array] p:total => ObjectSpace :: AllocationTracer.Allocated_count_table.values.inject.inoject(:+)结束def make_gems save_loaded_features do num_of_pkg = 7 num_of_version_per_pkg = 3包=(0..num_of_pkg).map do | pkgi | (0..num_of_version_per_pkg).map do | pkg_version | deps = hash [(pkgi..num_of_pkg).map {| deppkgi | [" pkg#{deppkgi}""> = 0"]}] new_spec" pkg#{pkgi}",pkg_version.to_s,deps结束结束基础= new_spec" pkg_base&#34 ;," 1",{" pkg0" => "> = 0"} gem :: specification.reset install_specs base,* packages.flatten base.activate产量结束endend```before:{:total => 11173668}之后:{:总= > 2940}