@@ -1250,8 +1250,10 @@ end
1250
1250
1251
1251
1252
1252
"""
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=true, streaming::Bool=false)
1255
+ Profile.take_heap_snapshot(all_one::Bool=false; redact_data:Bool=true,
1256
+ dir::String=nothing, streaming::Bool=false)
1255
1257
1256
1258
Write a snapshot of the heap, in the JSON format expected by the Chrome
1257
1259
Devtools Heap Snapshot viewer (.heapsnapshot extension) to a file
@@ -1262,6 +1264,8 @@ full file path, or IO stream.
1262
1264
If `all_one` is true, then report the size of every object as one so they can be easily
1263
1265
counted. Otherwise, report the actual size.
1264
1266
1267
+ If `redact_data` is true (default), then do not emit the contents of any object.
1268
+
1265
1269
If `streaming` is true, we will stream the snapshot data out into four files, using filepath
1266
1270
as the prefix, to avoid having to hold the entire snapshot in memory. This option should be
1267
1271
used 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
1277
1281
parts in the same directory as your provided filepath, so you can still reconstruct the
1278
1282
snapshot after the fact, via `assemble_snapshot()`.
1279
1283
"""
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 = true , streaming:: Bool = false )
1281
1285
if streaming
1282
- _stream_heap_snapshot (filepath, all_one)
1286
+ _stream_heap_snapshot (filepath, all_one, redact_data )
1283
1287
else
1284
1288
# Support the legacy, non-streaming mode, by first streaming the parts, then
1285
1289
# reassembling it after we're done.
1286
1290
prefix = filepath
1287
- _stream_heap_snapshot (prefix, all_one)
1291
+ _stream_heap_snapshot (prefix, all_one, redact_data )
1288
1292
Profile. HeapSnapshot. assemble_snapshot (prefix, filepath)
1289
1293
Profile. HeapSnapshot. cleanup_streamed_files (prefix)
1290
1294
end
1291
1295
return filepath
1292
1296
end
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 = true )
1294
1298
# Support the legacy, non-streaming mode, by first streaming the parts to a tempdir,
1295
1299
# then reassembling it after we're done.
1296
1300
dir = tempdir ()
1297
1301
prefix = joinpath (dir, " snapshot" )
1298
- _stream_heap_snapshot (prefix, all_one)
1302
+ _stream_heap_snapshot (prefix, all_one, redact_data )
1299
1303
Profile. HeapSnapshot. assemble_snapshot (prefix, io)
1300
1304
end
1301
- function _stream_heap_snapshot (prefix:: AbstractString , all_one:: Bool )
1305
+ function _stream_heap_snapshot (prefix:: AbstractString , all_one:: Bool , redact_data :: Bool )
1302
1306
# Nodes and edges are binary files
1303
1307
open (" $prefix .nodes" , " w" ) do nodes
1304
1308
open (" $prefix .edges" , " w" ) do edges
@@ -1311,9 +1315,9 @@ function _stream_heap_snapshot(prefix::AbstractString, all_one::Bool)
1311
1315
Base. @_lock_ios (json,
1312
1316
ccall (:jl_gc_take_heap_snapshot ,
1313
1317
Cvoid,
1314
- (Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid}, Cchar),
1318
+ (Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid}, Cchar, Cchar ),
1315
1319
nodes. handle, edges. handle, strings. handle, json. handle,
1316
- Cchar (all_one))
1320
+ Cchar (all_one), Cchar (redact_data) )
1317
1321
)
1318
1322
)
1319
1323
)
@@ -1323,7 +1327,7 @@ function _stream_heap_snapshot(prefix::AbstractString, all_one::Bool)
1323
1327
end
1324
1328
end
1325
1329
end
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 ; dir:: Union{Nothing,S} = nothing , kwargs ... ) where {S <: AbstractString }
1327
1331
fname = " $(getpid ()) _$(time_ns ()) .heapsnapshot"
1328
1332
if isnothing (dir)
1329
1333
wd = pwd ()
@@ -1338,7 +1342,7 @@ function take_heap_snapshot(all_one::Bool=false; dir::Union{Nothing,S}=nothing)
1338
1342
else
1339
1343
fpath = joinpath (expanduser (dir), fname)
1340
1344
end
1341
- return take_heap_snapshot (fpath, all_one)
1345
+ return take_heap_snapshot (fpath, all_one; kwargs ... )
1342
1346
end
1343
1347
1344
1348
"""
0 commit comments