raco pollen start: memory usage slowly creeps up every refresh #149

Closed
opened 7 years ago by kisaragi-hiu · 10 comments
kisaragi-hiu commented 7 years ago (Migrated from github.com)

Upon each refresh, the memory usage goes up by about 1MB.
As I'm embedding live.js in my template.html to auto refresh the page, my system eventually ran out of memory.
I've tried to run the racket insta web app example (https://docs.racket-lang.org/continue/index.html?q=web%20applications) in DrRacket, which doesn't seem to increase its memory usage every refresh.
(I never see memory usage decrease with raco pollen start, whereas drracket's memory usage does fluctuate)
Currently I put raco pollen start in a while loop that kills raco after 10 minutes then repeats, which partly solves the issue.

Upon each refresh, the memory usage goes up by about 1MB. As I'm embedding live.js in my template.html to auto refresh the page, my system eventually ran out of memory. I've tried to run the racket insta web app example (https://docs.racket-lang.org/continue/index.html?q=web%20applications) in DrRacket, which doesn't seem to increase its memory usage every refresh. (I never see memory usage decrease with `raco pollen start`, whereas drracket's memory usage does fluctuate) Currently I put `raco pollen start` in a while loop that kills raco after 10 minutes then repeats, which partly solves the issue.
mbutterick commented 7 years ago (Migrated from github.com)

Interesting.

  1. What version of Racket?
  2. How are you monitoring memory usage?
Interesting. 1) What version of Racket? 2) How are you monitoring memory usage?
kisaragi-hiu commented 7 years ago (Migrated from github.com)
~  racket --version
Welcome to Racket v6.10.
~ 

I look at the memory usage in gnome-system-monitor.

Also, my pollen.rkt:

#lang racket
(require pollen/decode txexpr)
(require pollen/tag)
(provide (all-defined-out))

; newline decoder
(provide root)
(define (root . elements)
   (txexpr 'root empty (decode-elements elements
     #:txexpr-elements-proc decode-paragraphs)))

(define topic (default-tag-function 'h1))
(define items (default-tag-function 'ul))
(define item (default-tag-function 'li 'p))
(define notes (default-tag-function 'pre 'code))

; link functions
(define (link url text) `(a ((href ,url) (target "_blank")) ,text))
(define (pixiv username text) (link (string-append "https://pixiv.me/" username) text))
(define (github name text) (link (string-append "https://github.com/" name) text))

And my template.html:

<html>
    <script type="text/javascript" src="http://livejs.com/live.js"></script>
    <head><meta charset="UTF-8"></head>
    <style type="text/css">
body{
    font-family: 'Overpass Regular', 'Noto Sans CJK TC Light', sans-serif;
}
h1 {
    font-family: 'Overpass Regular', 'Noto Sans CJK TC Regular', sans-serif;
}
    </style>
    <body>
        ◊(->html ◊doc)
    </body>
</html>
``` ~  racket --version Welcome to Racket v6.10. ~  ``` I look at the memory usage in `gnome-system-monitor`. Also, my `pollen.rkt`: ``` #lang racket (require pollen/decode txexpr) (require pollen/tag) (provide (all-defined-out)) ; newline decoder (provide root) (define (root . elements) (txexpr 'root empty (decode-elements elements #:txexpr-elements-proc decode-paragraphs))) (define topic (default-tag-function 'h1)) (define items (default-tag-function 'ul)) (define item (default-tag-function 'li 'p)) (define notes (default-tag-function 'pre 'code)) ; link functions (define (link url text) `(a ((href ,url) (target "_blank")) ,text)) (define (pixiv username text) (link (string-append "https://pixiv.me/" username) text)) (define (github name text) (link (string-append "https://github.com/" name) text)) ``` And my `template.html`: ``` <html> <script type="text/javascript" src="http://livejs.com/live.js"></script> <head><meta charset="UTF-8"></head> <style type="text/css"> body{ font-family: 'Overpass Regular', 'Noto Sans CJK TC Light', sans-serif; } h1 { font-family: 'Overpass Regular', 'Noto Sans CJK TC Regular', sans-serif; } </style> <body> ◊(->html ◊doc) </body> </html> ```
mbutterick commented 7 years ago (Migrated from github.com)

As I'm embedding live.js in my template.html to auto refresh the page, my system eventually ran out of memory.

What happens if you remove live.js? (I’m not clear why you need this script anyhow, since Pollen’s project server will refresh changed files automatically)

> As I'm embedding live.js in my template.html to auto refresh the page, my system eventually ran out of memory. What happens if you remove `live.js`? (I’m not clear why you need this script anyhow, since Pollen’s project server will refresh changed files automatically)
kisaragi-hiu commented 7 years ago (Migrated from github.com)

Sorry for the delay, had to sleep & go to school.

If I remove live.js, the memory usage would simply go up by about 1MB every time I refresh. All effect live.js has is just refreshing the page every second or so.
The files may be updated, but the browser doesn't know about it until refreshed or somehow notified, that's why I'm using the script.

Sorry for the delay, had to sleep & go to school. If I remove `live.js`, the memory usage would simply go up by about 1MB every time I refresh. All effect live.js has is just refreshing the page every second or so. The files may be updated, but the browser doesn't know about it until refreshed or somehow notified, that's why I'm using the script.
mbutterick commented 7 years ago (Migrated from github.com)

Does the memory leak also show up in top (say, in the MEM column)? That would be an easier way for me to assess what’s happening.

FWIW, when I watch top on Mac OS while Pollen runs, on a refresh I see the memory usage jump up for a few seconds, but then decline (as GC kicks in)

Does the memory leak also show up in `top` (say, in the `MEM` column)? That would be an easier way for me to assess what’s happening. FWIW, when I watch `top` on Mac OS while Pollen runs, on a refresh I see the memory usage jump up for a few seconds, but then decline (as GC kicks in)
kisaragi-hiu commented 7 years ago (Migrated from github.com)

It's the same in top, the memory usage does not drop. I'm currently on Arch, and the only raco packages I have installed are main-distribution, racket-lib, and pollen.

I've tried to create a new project: mkdir /tmp/pollentest; cd /tmp/pollentest; raco pollen start, then navigating to the project dashboard, localhost:8080, and monitoring the RES column in top. It starts at 147.4m, and goes up by about 0.3m every refresh, without ever droping.

I'm on Pollen 1.2.1468.852 (Racket 6.10) right now, just updated.

It's the same in `top`, the memory usage does not drop. I'm currently on Arch, and the only raco packages I have installed are `main-distribution`, `racket-lib`, and `pollen`. I've tried to create a new project: `mkdir /tmp/pollentest; cd /tmp/pollentest; raco pollen start`, then navigating to the project dashboard, `localhost:8080`, and monitoring the RES column in `top`. It starts at 147.4m, and goes up by about 0.3m every refresh, without ever droping. I'm on Pollen 1.2.1468.852 (Racket 6.10) right now, just updated.
mbutterick commented 7 years ago (Migrated from github.com)

I'm testing your files in Ubuntu 16.04 with Racket 6.10. I’m not able to duplicate the problem yet — in gnome-system-monitor, the memory usage for raco pollen start goes up during a refresh (about 50-100 mb), but then goes down as garbage collection kicks in.

So I’m even more perplexed by this part of your bug report:

I never see memory usage decrease with raco pollen start, whereas drracket's memory usage does fluctuate … It starts at 147.4m, and goes up by about 0.3m every refresh, without ever droping.

I see raco pollen start constantly fluctuating (as I would expect).

I'm testing your files in Ubuntu 16.04 with Racket 6.10. I’m not able to duplicate the problem yet — in `gnome-system-monitor`, the memory usage for `raco pollen start` goes up during a refresh (about 50-100 mb), but then goes down as garbage collection kicks in. So I’m even more perplexed by this part of your bug report: > I never see memory usage decrease with raco pollen start, whereas drracket's memory usage does fluctuate … It starts at 147.4m, and goes up by about 0.3m every refresh, without ever droping. I see `raco pollen start` constantly fluctuating (as I would expect).
kisaragi-hiu commented 7 years ago (Migrated from github.com)

Maybe somehow it's only happening in Arch-based distros? I've tried to install it in a Manjaro live session, and the leak is apparent there as well. This seems like a issue with either my system, Arch, or Racket actually...

Maybe somehow it's only happening in Arch-based distros? I've tried to install it in a Manjaro live session, and the leak is apparent there as well. This seems like a issue with either my system, Arch, or Racket actually...
mbutterick commented 7 years ago (Migrated from github.com)

Unfortunately I don’t have a way of testing this on Arch Linux. Though even then, I wouldn’t know why the problem is occurring or how to fix it. If memory isn’t getting released at all, that does seem like a deeper issue (Pollen doesn’t do any memory management).

The best I can do for now is leave the issue open in case you or someone else discovers the underlying cause.

Unfortunately I don’t have a way of testing this on Arch Linux. Though even then, I wouldn’t know why the problem is occurring or how to fix it. If memory isn’t getting released at all, that does seem like a deeper issue (Pollen doesn’t do any memory management). The best I can do for now is leave the issue open in case you or someone else discovers the underlying cause.
kisaragi-hiu commented 6 years ago (Migrated from github.com)

I'm closing this as it's probably a problem in my own environment.

I'm closing this as it's probably a problem in my own environment.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#149
Loading…
There is no content yet.