Skip to content

Commit

Permalink
tidy up streamed files when not requesting streaming mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Mar 24, 2024
1 parent 68d4c0e commit a2aa08e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@ function take_heap_snapshot(filepath::AbstractString, all_one::Bool=false; strea
prefix = filepath
_stream_heap_snapshot(prefix, all_one)
Profile.HeapSnapshot.assemble_snapshot(prefix, filepath)
Profile.HeapSnapshot.cleanup_streamed_files(prefix)
end
return filepath
end
Expand Down
13 changes: 13 additions & 0 deletions stdlib/Profile/src/heapsnapshot_reassemble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ function assemble_snapshot(in_prefix, io::IO)
return nothing
end

"""
cleanup_streamed_files(prefix::AbstractString)
Remove files streamed during `take_heap_snapshot` in streaming mode.
"""
function cleanup_streamed_files(prefix::AbstractString)
rm(string(prefix, ".metadata.json"))
rm(string(prefix, ".nodes"))
rm(string(prefix, ".edges"))
rm(string(prefix, ".strings"))
return nothing
end

function print_str_escape_json(stream::IO, s::AbstractString)
print(stream, '"')
for c in s
Expand Down

0 comments on commit a2aa08e

Please sign in to comment.