[racket] Profiling memory use

131 views
Skip to first unread message

Daniel Prager

unread,
Feb 11, 2014, 3:13:45 AM2/11/14
to Racket Users
Is there a good reference to measure and understand Racket memory use?

I'm doing a run of scribble and memory use is peaking at over 1 Gb. 

I expect that I will be able to make modifications to limit use if I can get some informative measurements.


Thanks

Dan

--
Daniel Prager
Agile/Lean Coaching, Software Development and Leadership
Twitter: @agilejitsu 

Daniel Prager

unread,
Feb 13, 2014, 5:05:39 PM2/13/14
to Racket Users
Apropos:

I was wondering why I couldn't limit memory in a Racket program directly -- for running from the command-line -- as distinct from in Dr Racket, but the following transcript shed doubts on Dr Racket:

Welcome to DrRacket, version 5.3.6 [3m].
Language: racket; memory limit: 256 MB.

> (/ (current-memory-use) (expt 10 6))
900 52839/125000

> (collect-garbage)
> (/ (current-memory-use) (expt 10 6))
660 25687/31250

[Replicated in 5.91.]

Does (current-memory-use) include overhead for e.g. the DrRacket runtime?


Thanks

Dan

Robby Findler

unread,
Feb 13, 2014, 5:13:33 PM2/13/14
to Daniel Prager, Racket Users
current-memory-use is counting all of DrRacket's memory and the user program memory. The limit, however, includes only the user program's memory.

Robby


____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Daniel Prager

unread,
Feb 13, 2014, 5:22:35 PM2/13/14
to Robby Findler, Racket Users
Thanks Robby

Can the limit be imposed programmatically, for use from the command-line?


Thanks

Dan

Robby Findler

unread,
Feb 13, 2014, 5:24:48 PM2/13/14
to Daniel Prager, Racket Users
Yes. DrRacket does it. You'd have to use lower-level operations, tho (setting up a custodian with a limit before starting the program you want limited).

Robby

Daniel Prager

unread,
Feb 13, 2014, 5:35:11 PM2/13/14
to Robby Findler, Racket Users
Makes sense.

So -- correct me if I'm wrong ;-) -- my main choices are to use a Custodian to impose a hard memory limit, and/or throw in tactical  (collect-garbage)'s to help keep usage down.

In terms of profiling where the memory is going, are there any sharper tools than (current-memory-in-use)? 


Thanks again

Dan

Robby Findler

unread,
Feb 13, 2014, 5:42:27 PM2/13/14
to Daniel Prager, Racket Users
There is the sgc collector and there is the --enable-backtrace option to the 3m (default) collector. They can require some work to use, tho. They give you more information from dump-memory-stats, I believe (not sure exactly the status of sgc, tho).

Do you find tactical (collect-garbage) calls to actually help?

Robby

Reply all
Reply to author
Forward
0 new messages