@@ -297,12 +297,18 @@ on the author's laptop).
297297
298298# # Memory allocation analysis
299299
300- One of the most common techniques to improve performance is to reduce memory allocation. The
301- total amount of allocation can be measured with [` @time` ](@ref ) and [` @allocated` ](@ref ), and
300+ One of the most common techniques to improve performance is to reduce memory allocation. Julia
301+ provides several tools measure this:
302+
303+ # ## `@time`
304+
305+ The total amount of allocation can be measured with [` @time` ](@ref ) and [` @allocated` ](@ref ), and
302306specific lines triggering allocation can often be inferred from profiling via the cost of garbage
303307collection that these lines incur. However, sometimes it is more efficient to directly measure
304308the amount of memory allocated by each line of code.
305309
310+ # ## Line-by-Line Allocation Tracking
311+
306312To measure allocation line- by- line, start Julia with the ` --track-allocation=<setting>` command- line
307313option, for which you can choose ` none` (the default, do not measure allocation), ` user` (measure
308314memory allocation everywhere except Julia' s core code), or ` all` (measure memory allocation at
@@ -321,6 +327,15 @@ you want to analyze, then call [`Profile.clear_malloc_data()`](@ref) to reset al
321327 Finally, execute the desired commands and quit Julia to trigger the generation of the ` .mem`
322328files.
323329
330+ # ## GC Logging
331+
332+ While [` @time` ](@ref ) logs high- level stats about memory usage and garbage collection over the course
333+ of evaluating an expression, it can be useful to log each garbage collection event, to get an
334+ intuitive sense of how often the garbage collector is running, how long it' s running each time,
335+ and how much garbage it collects each time. This can be enabled with
336+ [` GC.enable_logging(true)` ](@ref ), which causes Julia to log to stderr every time
337+ a garbage collection happens.
338+
324339# # External Profiling
325340
326341Currently Julia supports ` Intel VTune` , ` OProfile` and ` perf` as external profiling tools.
0 commit comments