#include "string-convert.hh"
#include "warn.hh"
-/* Write midi as formatted ascii stream? */
-bool do_midi_debugging_global;
bool debug_skylines;
/*
profile_property_accesses = to_boolean (val);
val = scm_from_bool (to_boolean (val));
}
- else if (var == ly_symbol2scm ("debug-midi"))
- {
- do_midi_debugging_global = to_boolean (val);
- val = scm_from_bool (to_boolean (val));
- }
else if (var == ly_symbol2scm ("point-and-click"))
{
point_and_click_global = to_boolean (val);
(debug-gc-assert-parsed-dead #f "for memory debugging:
ensure that all refs to parsed objects are dead. This is an internal option, and is switched on automatically for -ddebug-gc.")
(debug-lexer #f "debug the flex lexer")
- (debug-midi #f "generate human readable MIDI")
(debug-parser #f "debug the bison parser")
(debug-skylines #f "debug skylines")
(delete-intermediate-files #f
(use-modules (ice-9 regex)
(ice-9 safe)
+ (ice-9 rdelim)
(ice-9 optargs)
(oop goops)
(srfi srfi-1)
(define gc-dumping #f)
(define gc-protect-stat-count 0)
+
+(define-public (dump-live-object-stats outfile)
+ (for-each
+ (lambda (x)
+ (format outfile "~a: ~a\n" (car x) (cdr x)))
+ (sort (gc-live-object-stats)
+ (lambda (x y)
+ (string<? (car x) (car y))))))
+
(define-public (dump-gc-protects)
(set! gc-protect-stat-count (1+ gc-protect-stat-count))
(let* ((protects (sort
(set! stats (gc-live-object-stats))
(display "Dumping live object statistics.\n")
-
- (for-each
- (lambda (x)
- (format outfile "~a: ~a\n" (car x) (cdr x)))
- (sort (gc-live-object-stats)
- (lambda (x y)
- (string<? (car x) (car y)))))))
-
+ (dump-live-object-stats outfile)))
(newline outfile)
(let*
)))
(set! gc-dumping #f)
+ (close-port outfile)
+
+ ))
+
+
+(define (check-memory)
+ "read /proc/self to check up on memory use."
+ (define (gulp-file name)
+ (let* ((file (open-input-file name))
+ (text (read-delimited "" file)))
+ (close file)
+ text))
+ (let*
+ ((stat (gulp-file "/proc/self/status"))
+ (lines (string-split stat #\newline))
+ (interesting (filter identity
+ (map
+ (lambda (l)
+ (string-match "^VmData:[ \t]*([0-9]*) kB" l))
+ lines)))
+ (mem (string->number (match:substring (car interesting) 1)))
+ )
+
+
+ (display (format "VMDATA: ~a\n" mem))
+ (display (gc-stats))
+ (if (> mem 100000)
+ (begin
+ (dump-gc-protects)
+ (raise 1)))
))
(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)