- (lilypond-file handler x)
- (ly:clear-anonymous-modules)
- (if (ly:get-option 'debug-gc)
- (dump-gc-protects)
- (if (= (rand 40) 1)
- (ly:reset-all-fonts))))
+ (let*
+ ((start-measurements (if do-measurements
+ (profile-measurements)
+ #f))
+ (base (basename x ".ly"))
+ (all-settings (ly:all-options)))
+
+ (if separate-logs
+ (ly:stderr-redirect (format "~a.log" base) "w"))
+ (if (ly:get-option 'trace-memory-frequency)
+ (mtrace:start-trace (ly:get-option 'trace-memory-frequency)))
+
+ (lilypond-file handler x)
+ (if start-measurements
+ (dump-profile x start-measurements (profile-measurements)))
+
+ (if (ly:get-option 'trace-memory-frequency)
+ (begin
+ (mtrace:stop-trace)
+ (mtrace:dump-results base)))
+
+ (for-each
+ (lambda (s)
+ (ly:set-option (car s) (cdr s)))
+ all-settings)
+
+ (ly:clear-anonymous-modules)
+ (ly:set-option 'debug-gc-assert-parsed-dead #t)
+ (gc)
+ (ly:set-option 'debug-gc-assert-parsed-dead #f)
+
+
+ (if (ly:get-option 'debug-gc)
+ (dump-gc-protects)
+ (if (= (random 40) 1)
+ (ly:reset-all-fonts)))))