This package provides a way to examine allocation profiles in Julia
that is more user-friendly than the built-in function
Profile.Allocs.print,
but at the same time more lightweight than the graphical solutions
ProfileCanvas.jl
and
PProf.jl.
The installed size of AllocationViewer.jl is 1.3 MB (source plus compiled code, excluding
standard library packages), compared to 12 MB for ProfileCanvas.jl (v0.1.7) and 260 MB for PProf.jl (v3.2.0).
Allocations can be filtered by type and size as well as source location (package, file and line number) and function name of a stack frame. They are displayed in collapsible menus (provided by FoldingTrees.jl). The top of the menu displays a summary of the allocations matching the given filter criteria and those that don't (if any). The first menu level shows the number and total size of the allocations occurring at each source line. The next level lists each such allocation together with its size and type. The third level shows the stack frames leading up to that source location.
Pressing the space bar on a menu item expands or collapses that item.
Pressing 'e' on a line mentioning a source location open an editor at that line;
'q' or ENTER quits the menu.
See the docstrings for @track_allocs and @framefilter for more details.
Here we investigate allocations that happen in iterate methods defined
in the package Combinatorics.jl and that are not of type Memory:
julia> using AllocationViewer, Combinatorics
julia> @track_allocs sum(permutations(1:3)) "@Combinatorics" && :iterate && !Memory
33 allocs: 1296 bytes at 3 source locations (ignoring 39 allocs: 1544 bytes)
+ 12 allocs: 576 bytes at @Combinatorics/src/permutations.jl:37 iterate
9 allocs: 336 bytes at @Combinatorics/src/permutations.jl:28 iterate
+ 32 bytes for Vector{Int64}
+ 32 bytes for Vector{Int64}
80 bytes for Dict{Int64, Nothing}
> @Combinatorics/src/permutations.jl:28 iterate
@Combinatorics/src/permutations.jl:27 iterate
@Base/reduce.jl:48 _foldl_impl
@Base/reduce.jl:40 foldl_impl
@Base/reduce.jl:36 mapfoldl_impl
@Base/reduce.jl:167 #mapfoldl#270
@Base/reduce.jl:167 mapfoldl
@Base/reduce.jl:299 #mapreduce#274
@Base/reduce.jl:299 mapreduce
@Base/reduce.jl:524 #sum#277
@Base/reduce.jl:524 sum
@Base/reduce.jl:553 #sum#278
@Base/reduce.jl:553 sum
+ 32 bytes for Vector{Int64}
+ 32 bytes for Vector{Int64}
+ 32 bytes for Vector{Vector{Int64}}
+ 32 bytes for Vector{Int64}
+ 32 bytes for Vector{Int64}
+ 32 bytes for Vector{Int64}
+ 12 allocs: 384 bytes at @Combinatorics/src/permutations.jl:287 iterate
The menu actually uses colors to help distinguish the various packages and types more easily.