@@ -1250,8 +1250,10 @@ end
12501250
12511251
12521252"""
1253- Profile.take_heap_snapshot(filepath::String, all_one::Bool=false, streaming=false)
1254- Profile.take_heap_snapshot(all_one::Bool=false; dir::String, streaming=false)
1253+ Profile.take_heap_snapshot(filepath::String, all_one::Bool=false,
1254+ redact_data::Bool=false; streaming::Bool=false)
1255+ Profile.take_heap_snapshot(all_one::Bool=false, redact_data:Bool=false;
1256+ dir::String=nothing)
12551257
12561258Write a snapshot of the heap, in the JSON format expected by the Chrome
12571259Devtools Heap Snapshot viewer (.heapsnapshot extension) to a file
@@ -1262,6 +1264,8 @@ full file path, or IO stream.
12621264If `all_one` is true, then report the size of every object as one so they can be easily
12631265counted. Otherwise, report the actual size.
12641266
1267+ If `redact_data` is true, then do not emit the contents of any object.
1268+
12651269If `streaming` is true, we will stream the snapshot data out into four files, using filepath
12661270as the prefix, to avoid having to hold the entire snapshot in memory. This option should be
12671271used for any setting where your memory is constrained. These files can then be reassembled
@@ -1277,28 +1281,28 @@ backwards-compatibility) and your process is killed, note that this will always
12771281parts in the same directory as your provided filepath, so you can still reconstruct the
12781282snapshot after the fact, via `assemble_snapshot()`.
12791283"""
1280- function take_heap_snapshot (filepath:: AbstractString , all_one:: Bool = false ; streaming:: Bool = false )
1284+ function take_heap_snapshot (filepath:: AbstractString , all_one:: Bool = false , redact_data :: Bool = false ; streaming:: Bool = false )
12811285 if streaming
1282- _stream_heap_snapshot (filepath, all_one)
1286+ _stream_heap_snapshot (filepath, all_one, redact_data )
12831287 else
12841288 # Support the legacy, non-streaming mode, by first streaming the parts, then
12851289 # reassembling it after we're done.
12861290 prefix = filepath
1287- _stream_heap_snapshot (prefix, all_one)
1291+ _stream_heap_snapshot (prefix, all_one, redact_data )
12881292 Profile. HeapSnapshot. assemble_snapshot (prefix, filepath)
12891293 Profile. HeapSnapshot. cleanup_streamed_files (prefix)
12901294 end
12911295 return filepath
12921296end
1293- function take_heap_snapshot (io:: IO , all_one:: Bool = false )
1297+ function take_heap_snapshot (io:: IO , all_one:: Bool = false , redact_data :: Bool = false )
12941298 # Support the legacy, non-streaming mode, by first streaming the parts to a tempdir,
12951299 # then reassembling it after we're done.
12961300 dir = tempdir ()
12971301 prefix = joinpath (dir, " snapshot" )
1298- _stream_heap_snapshot (prefix, all_one)
1302+ _stream_heap_snapshot (prefix, all_one, redact_data )
12991303 Profile. HeapSnapshot. assemble_snapshot (prefix, io)
13001304end
1301- function _stream_heap_snapshot (prefix:: AbstractString , all_one:: Bool )
1305+ function _stream_heap_snapshot (prefix:: AbstractString , all_one:: Bool , redact_data :: Bool )
13021306 # Nodes and edges are binary files
13031307 open (" $prefix .nodes" , " w" ) do nodes
13041308 open (" $prefix .edges" , " w" ) do edges
@@ -1311,9 +1315,9 @@ function _stream_heap_snapshot(prefix::AbstractString, all_one::Bool)
13111315 Base. @_lock_ios (json,
13121316 ccall (:jl_gc_take_heap_snapshot ,
13131317 Cvoid,
1314- (Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid}, Cchar),
1318+ (Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid}, Cchar, Cchar ),
13151319 nodes. handle, edges. handle, strings. handle, json. handle,
1316- Cchar (all_one))
1320+ Cchar (all_one), Cchar (redact_data) )
13171321 )
13181322 )
13191323 )
@@ -1323,7 +1327,7 @@ function _stream_heap_snapshot(prefix::AbstractString, all_one::Bool)
13231327 end
13241328 end
13251329end
1326- function take_heap_snapshot (all_one:: Bool = false ; dir:: Union{Nothing,S} = nothing ) where {S <: AbstractString }
1330+ function take_heap_snapshot (all_one:: Bool = false , redact_data :: Bool = false ; dir:: Union{Nothing,S} = nothing ) where {S <: AbstractString }
13271331 fname = " $(getpid ()) _$(time_ns ()) .heapsnapshot"
13281332 if isnothing (dir)
13291333 wd = pwd ()
@@ -1338,7 +1342,7 @@ function take_heap_snapshot(all_one::Bool=false; dir::Union{Nothing,S}=nothing)
13381342 else
13391343 fpath = joinpath (expanduser (dir), fname)
13401344 end
1341- return take_heap_snapshot (fpath, all_one)
1345+ return take_heap_snapshot (fpath, all_one, redact_data )
13421346end
13431347
13441348"""
0 commit comments