Skip to content

Commit

Permalink
Suggestion: Print Allocation in red
Browse files Browse the repository at this point in the history
This makes it a bit easier to identify individual allocation instances when a vector of them is printed in the REPL
  • Loading branch information
baggepinnen authored Oct 9, 2023
1 parent 0d48076 commit 0dafb1a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AllocCheck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ function Base.show(io::IO, alloc::AllocInstance)
typ = guess_julia_type(alloc.inst)

if length(alloc.backtrace) == 0
Base.println(io, "Allocation of ", typ, " in ")
Base.printstyled(io, "Allocation", color=:red, bold=true)
Base.println(io, " of ", typ, " in ")
Base.println(io, alloc.inst)
else
Base.println(io, "Allocation of ", typ, " in ", alloc.backtrace[1].file, ":", alloc.backtrace[1].line)
Base.printstyled(io, "Allocation", color=:red, bold=true)
Base.println(io, " of ", typ, " in ", alloc.backtrace[1].file, ":", alloc.backtrace[1].line)

# Print code excerpt of allocation site
try
Expand Down

0 comments on commit 0dafb1a

Please sign in to comment.