+ (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)))