diff --git a/collects/drscheme/private/main.ss b/collects/drscheme/private/main.ss index c05c2ff8d0..cc60fdf367 100644 --- a/collects/drscheme/private/main.ss +++ b/collects/drscheme/private/main.ss @@ -71,7 +71,7 @@ (number? (car x)) (number? (cdr x)))))) -(preferences:set-default 'drscheme:limit-memory #f +(preferences:set-default 'drscheme:limit-memory (* 1024 1024 128) (λ (x) (or (boolean? x) (integer? x) (x . >= . (* 1024 1024 100))))) diff --git a/collects/drscheme/private/rep.ss b/collects/drscheme/private/rep.ss index 637bc1c582..5e05dcc505 100644 --- a/collects/drscheme/private/rep.ss +++ b/collects/drscheme/private/rep.ss @@ -532,25 +532,6 @@ TODO (make-object image-snip% bitmap) (make-object string-snip% "[err]")))) - (define (no-user-evaluation-message frame exit-code memory-killed?) - (message-box - (string-constant evaluation-terminated) - (string-append - (string-constant evaluation-terminated-explanation) - (if exit-code - (string-append - "\n\n" - (if (zero? exit-code) - (string-constant exited-successfully) - (format (string-constant exited-with-error-code) exit-code))) - "") - (if memory-killed? - (string-append - "\n\n" - (string-constant program-ran-out-of-memory)) - "")) - frame)) - ;; insert/delta : (instanceof text%) (union snip string) (listof style-delta%) *-> (values number number) ;; inserts the string/stnip into the text at the end and changes the ;; style of the newly inserted text based on the style deltas. @@ -970,6 +951,38 @@ TODO (not (thread-running? memory-killed-thread)))))) (field (need-interaction-cleanup? #f)) + (define/private (no-user-evaluation-message frame exit-code memory-killed?) + (let* ([new-limit (and custodian-limit (+ (* 1024 1024 128) custodian-limit))] + [ans (message-box/custom + (string-constant evaluation-terminated) + (string-append + (string-constant evaluation-terminated-explanation) + (if exit-code + (string-append + "\n\n" + (if (zero? exit-code) + (string-constant exited-successfully) + (format (string-constant exited-with-error-code) exit-code))) + "") + (if memory-killed? + (string-append + "\n\n" + (string-constant program-ran-out-of-memory)) + "")) + (string-constant ok) + #f + (and memory-killed? + new-limit + (format "Increase memory limit to ~a megabytes" + (floor (/ new-limit 1024 1024)))) + frame + '(default=1 stop) + )]) + (when (equal? ans 3) + (set-custodian-limit new-limit) + (preferences:set 'drscheme:limit-memory new-limit)) + (void))) + (define/private (cleanup-interaction) ; =Kernel=, =Handler= (set! need-interaction-cleanup? #f) (begin-edit-sequence) diff --git a/collects/mred/private/editor.ss b/collects/mred/private/editor.ss index 0812ed8710..add690a678 100644 --- a/collects/mred/private/editor.ss +++ b/collects/mred/private/editor.ss @@ -81,6 +81,20 @@ set-modified set-filename get-file put-file get-max-undo-history) + (rename-super [super-on-char on-char]) + (define time 0) + (define count 0) + (override* [on-char + (λ (evt) + (let-values ([(results cpu real gc) + (time-apply (λ () (super-on-char evt)) '())]) + (set! time (+ real time)) + (set! count (+ count 1)) + (when (= count 20) + (printf "time ~s\n" time) + (set! count 0) + (set! time 0)) + (apply values results)))]) (define canvases null) (define active-canvas #f) (define auto-set-wrap? #f)