racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
444 stars 93 forks source link

Memory leaks to 32gb within 10 seconds #646

Open CornFarmerNZ opened 8 months ago

CornFarmerNZ commented 8 months ago

What version of Racket are you using? version 8.9 [cs].

What program did you run? Dragged two .rkt files into DrRacket, one by one, then switch between the tabs.

What should have happened? Should be able to tab in-between the two .rkt files without memory usage instantly start rising by about 2gb/second.

If you got an error message, please include it here.

Screenshot 2023-10-17 at 12 57 05 PM

Please include any other relevant details PC: M1 Mac OS: Sonoma 14.0

rfindler commented 8 months ago

Dragging two simple files (eg files that have only #lang racket/base at the top) doesn't seem to cause any issues, so it probably has something to do with what's in those two files.

Do you have the memory limit turned on (in the "Racket" menu, the "Limit Memory..." menu item)? If not, it may be that expanded the contents of the files uses an unbounded amount of memory (or maybe just a lot of memory).

CornFarmerNZ commented 8 months ago

Dragging two simple files (eg files that have only #lang racket/base at the top) doesn't seem to cause any issues, so it probably has something to do with what's in those two files.

Do you have the memory limit turned on (in the "Racket" menu, the "Limit Memory..." menu item)? If not, it may be that expanded the contents of the files uses an unbounded amount of memory (or maybe just a lot of memory).

I have a (Default?) limit of 128mb. Additionally, having the files open by their own (or having them both as tabs but never switching to the other) does not increase the memory usage abnormally - only when tabbing between the two. Also, everything seems to work as expected when using my Windows pc.

File 1:

#lang eopl

(define the-lexical-spec
  '((whitespace (whitespace) skip)
    (comment ("%" (arbno (not #\newline))) skip)
    (identifier
     (letter (arbno (or letter digit "_" "-" "?"))) symbol)
    (keyword ("=") string)
    (number (digit (arbno digit)) number)))

(define the-grammar
  '(
    (program (expression) a-program)
    (expression (number) lit-exp)
    (expression (identifier) var-exp)
    (expression (primitive "(" (separated-list expression ",") ")") primapp-exp)
    (primitive ("+") add-prim)
    (primitive ("-") subtract-prim)
    (primitive ("add1") incr-prim)
    (primitive ("sub1") decr-prim)
    ))

; (define-datatype program program?
;   (a-program
;    (exp expression?)))
; 
; (define-datatype expression expression?
;   (lit-exp (datum number?))
;   (var-exp (id symbol?))
;   (primapp-exp (prim primitive?)
;                (rands (list-of expression?))))
; 
; (define-datatype primitive primitive?
;   (add-prim)
;   (subtract-prim)
;   (mult-prim)
;   (incr-prim)
;   (decr-prim))

;;;;;;;;;;;;;;;; sllgen boilerplate ;;;;;;;;;;;;;;;;

(sllgen:make-define-datatypes the-lexical-spec the-grammar)

(define show-the-datatypes
    (lambda () (sllgen:list-define-datatypes the-lexical-spec the-grammar)))

(define scan&parse
    (sllgen:make-string-parser the-lexical-spec the-grammar))

(define just-scan
    (sllgen:make-string-scanner the-lexical-spec the-grammar))

(define stmt1 "5")
(define stmt2 "x")
(define stmt3 "+(3,x)")
(define stmt4 "add1(+(4,x))")

File 2:

#lang eopl

(define the-lexical-spec
  '((whitespace (whitespace) skip)
    (comment ("//" (arbno (not #\newline))) skip) 
    (identifier ("=") string)
    (number (digit (arbno digit)) number)
  ))

(define the-grammar
  '(
    (program (statement) a-program)
    (statement (number) lit-exp)
    (statement (identifier) var-exp)
    (statement ("const" name) stmt-name)
    ;;(statement ("const" name "(" (separated-list name ",") ")" block) stmt-name)
    ))

; (define-datatype program program?
;   (a-program
;    (statement statement?)))
; 
; (define-datatype statement statement?
;   (lit-exp (datum number?))
;   (var-exp (id symbol?)))
; 
; (define-datatype name name?
;   (stmt-name (id string?))
;   )
; 

;;;;;;;;;;;;;;;; sllgen boilerplate ;;;;;;;;;;;;;;;;

(sllgen:make-define-datatypes the-lexical-spec the-grammar)

(define show-the-datatypes
    (lambda () (sllgen:list-define-datatypes the-lexical-spec the-grammar)))

(define scan&parse
    (sllgen:make-string-parser the-lexical-spec the-grammar))

(define just-scan
    (sllgen:make-string-scanner the-lexical-spec the-grammar))

(define stmt1 "5")
(define stmt2 "=")
;;(define stmt3 "+(3,x)")
;;(define stmt4 "add1(+(4,x))")
sorawee commented 8 months ago

I can't reproduce the problem as well.

Observation: in your screenshot, you have a comment box, which is not preserved when copying over as text. Still, even after adding a comment box to the programs manually, I can't reproduce the issue.

rfindler commented 8 months ago

It is possible to attach actual files here; that may matter. I'm not on sonoma yet, so it might be an interaction between that and something in one of the GUI libraries.

If it isn't either of those, then starting from the command-line and hitting control-c in the Terminal window while it is very busy may give us some information. Specifically, if you open a Terminal window and do this:

% /Applications/Racket\ v8.9/bin/drracket 

and then open the files in DrRacket as usual, and then make it start going crazy and then hit control-c back in the terminal window, if we're lucky you'll get a stacktrace that'll point to the misbehaving code and maybe we'll then be able to figure out what's going on.

CornFarmerNZ commented 8 months ago

It is possible to attach actual files here; that may matter. I'm not on sonoma yet, so it might be an interaction between that and something in one of the GUI libraries.

If it isn't either of those, then starting from the command-line and hitting control-c in the Terminal window while it is very busy may give us some information. Specifically, if you open a Terminal window and do this:

% /Applications/Racket\ v8.9/bin/drracket 

and then open the files in DrRacket as usual, and then make it start going crazy and then hit control-c back in the terminal window, if we're lucky you'll get a stacktrace that'll point to the misbehaving code and maybe we'll then be able to figure out what's going on.

I've just realised that it has been ~8-9 weeks of using DrRacket with no issues until now, right after I updated my MacOS version. Also, I tried with two different files and the same interaction occurs.

Screenshot 2023-10-18 at 5 51 26 PM