Skip to content

Commit a2aa08e

Browse files
tidy up streamed files when not requesting streaming mode
1 parent 68d4c0e commit a2aa08e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ function take_heap_snapshot(filepath::AbstractString, all_one::Bool=false; strea
12861286
prefix = filepath
12871287
_stream_heap_snapshot(prefix, all_one)
12881288
Profile.HeapSnapshot.assemble_snapshot(prefix, filepath)
1289+
Profile.HeapSnapshot.cleanup_streamed_files(prefix)
12891290
end
12901291
return filepath
12911292
end

stdlib/Profile/src/heapsnapshot_reassemble.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ function assemble_snapshot(in_prefix, io::IO)
203203
return nothing
204204
end
205205

206+
"""
207+
cleanup_streamed_files(prefix::AbstractString)
208+
209+
Remove files streamed during `take_heap_snapshot` in streaming mode.
210+
"""
211+
function cleanup_streamed_files(prefix::AbstractString)
212+
rm(string(prefix, ".metadata.json"))
213+
rm(string(prefix, ".nodes"))
214+
rm(string(prefix, ".edges"))
215+
rm(string(prefix, ".strings"))
216+
return nothing
217+
end
218+
206219
function print_str_escape_json(stream::IO, s::AbstractString)
207220
print(stream, '"')
208221
for c in s

0 commit comments

Comments
 (0)