Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created July 1, 2012 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmichaud/3030034 to your computer and use it in GitHub Desktop.
Save pmichaud/3030034 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/parrot$ cat gc-10.pir
.include 'interpinfo.pasm'
.sub 'main' :main
# This loop simply creates a large number of ResizablePMCArrays,
# releasing(?) any previously allocated RPA on each iteration
# through the loop.
$I0 = 0
loop:
unless $I0 < 10000000 goto done
$P0 = new ['ResizablePMCArray']
inc $I0
goto loop
done:
# Now display the current memory consumption statistics.
print "gc_mark_runs="
$I0 = interpinfo .INTERPINFO_GC_MARK_RUNS
say $I0
print "gc_collect_runs="
$I0 = interpinfo .INTERPINFO_GC_COLLECT_RUNS
say $I0
print "total_pmcs="
$I0 = interpinfo .INTERPINFO_TOTAL_PMCS
say $I0
print "active_pmcs="
$I0 = interpinfo .INTERPINFO_ACTIVE_PMCS
say $I0
print "total_mem_alloc="
$I0 = interpinfo .INTERPINFO_TOTAL_MEM_ALLOC
say $I0
print "total_mem_used="
$I0 = interpinfo .INTERPINFO_TOTAL_MEM_USED
say $I0
.end
pmichaud@kiwi:~/p6/parrot$ ./parrot gc-10.pir
gc_mark_runs=3
gc_collect_runs=0
total_pmcs=2990640
active_pmcs=1042668
total_mem_alloc=192630784
total_mem_used=58585563
pmichaud@kiwi:~/p6/parrot$
@leto
Copy link

leto commented Jul 1, 2012

The oddity of there being no collect runs may have something to do with the fact that all the RPA's that you create are in the same scope. It would be interesting to compare it to similar code which does exactly the same thing, but uses a PIR function instead of labels and goto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment