]> git.donarmstrong.com Git - lilypond.git/commitdiff
Strip midi-debugging ; add memory check to watch RSS value.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 17 Jan 2007 00:53:14 +0000 (01:53 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 17 Jan 2007 00:53:14 +0000 (01:53 +0100)
lily/program-option.cc
scm/lily.scm

index 8f593aaa393c3d9e8a8a28bbd3fecd25a258914b..5d9bebd7382728656addb4e9e5b01ac75fe1776c 100644 (file)
@@ -19,8 +19,6 @@ using namespace std;
 #include "string-convert.hh"
 #include "warn.hh"
 
-/* Write midi as formatted ascii stream? */
-bool do_midi_debugging_global;
 bool debug_skylines;
 
 /*
@@ -48,11 +46,6 @@ void internal_set_option (SCM var, SCM val)
       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);
index e10b4b7d3374b4d687ed282ea1988fcec87b012d..c8c3a010ac14856cbfab72bb61a87d6c8bfbef67 100644 (file)
@@ -36,7 +36,6 @@
              (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
@@ -100,6 +99,7 @@ on errors, and print a stack trace.")
 
 (use-modules (ice-9 regex)
             (ice-9 safe)
+            (ice-9 rdelim)
              (ice-9 optargs)
             (oop goops)
             (srfi srfi-1)
@@ -402,6 +402,15 @@ The syntax is the same as `define*-public'."
 
 (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
@@ -450,14 +459,7 @@ The syntax is the same as `define*-public'."
 
          (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*
@@ -479,6 +481,36 @@ The syntax is the same as `define*-public'."
                           )))
 
     (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)))
     
     ))
 
@@ -628,12 +660,12 @@ The syntax is the same as `define*-public'."
          (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)