File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 115115# Misc utils #
116116# #############
117117
118+ macro monitor_oom (ex)
119+ quote
120+ lowest_free_mem = Sys. free_memory ()
121+ mem_monitor = Timer (0 , interval = 1 ) do t
122+ lowest_free_mem = min (lowest_free_mem, Sys. free_memory ())
123+ end
124+ try
125+ $ (esc (ex))
126+ catch
127+ if lowest_free_mem < 512 * 1024 * 1024 # Less than 512 MB
128+ @warn """
129+ Free system memory dropped to $(Base. format_bytes (lowest_free_mem)) during sysimage compilation.
130+ If the reason the subprocess errored isn't clear, it may have been OOM-killed.
131+ """
132+ end
133+ rethrow ()
134+ finally
135+ close (mem_monitor)
136+ end
137+ end
138+ end
139+
118140const WARNED_CPP_COMPILER = Ref {Bool} (false )
119141
120142function get_compiler_cmd (; cplusplus:: Bool = false )
@@ -361,7 +383,7 @@ function create_sysimg_object_file(object_file::String,
361383 @debug " running $cmd "
362384 non = incremental ? " " : " non"
363385 spinner = TerminalSpinners. Spinner (msg = " PackageCompiler: compiling $(non) incremental system image" )
364- TerminalSpinners. @spin spinner run (cmd)
386+ @monitor_oom TerminalSpinners. @spin spinner run (cmd)
365387 return
366388end
367389
You can’t perform that action at this time.
0 commit comments