Your message dated Tue, 23 Jan 2007 15:05:16 +0000
with message-id <[EMAIL PROTECTED]>
and subject line randomRs now runs in constant space
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: ghc6
Version: 6.4.1-1
Severity: normal

  I was writing a program that needed large quantities of random numbers,
and so I used randomRs to generate a stream that I could consume:

map (lineChars!) $ randomRs (bounds lineChars) g

  lineChars is of course an array that I'm pulling elements from.  Imagine
my surprise when, within seconds of starting the compiled program, it had
eating 80% of my virtual memory space!  After learning how to use the GHC
heap profiler, I was able to trace my troubles to the above expression.
On a whim, I replaced it with the following expression (which ought to be
equivalent):

map (lineChars!) $ unfoldr (Just . randomR (bounds lineChars)) g

  As soon as I did so, the memory leak vanished.  I don't understand why
randomRs is eating tons of heap here, but it seems pretty clear that it's
the culprit.

  I've attached the full program for inspection; it generates a number of
lines (the number is given on the command-line) of random characters and
spits them to stdout.  The leak becomes pronounced when you get to around
50,000 to 100,000 lines of output.  The "toSplit" binding is the one that
leaks; I've included several alternative definitions, none of which leak.

  Daniel

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental'), (1, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages ghc6 depends on:
ii  gcc                           4:4.0.2-2  The GNU C compiler
ii  haskell-utils                 1.6.0.1    Utilities used by the Debian Haske
ii  libc6                         2.3.5-12   GNU C Library: Shared libraries an
ii  libgmp3-dev                   4.1.4-11   Multiprecision arithmetic library 
ii  libgmp3c2                     4.1.4-11   Multiprecision arithmetic library
ii  libncurses5                   5.5-1      Shared libraries for terminal hand
ii  libreadline5                  5.1-5      GNU readline and history libraries
ii  libreadline5-dev              5.1-5      GNU readline and history libraries
ii  perl [perl5]                  5.8.7-10   Larry Wall's Practical Extraction 

ghc6 recommends no packages.

-- no debconf information

Attachment: signature.asc
Description: Digital signature


--- End Message ---
--- Begin Message ---
Version: 6.6-1

As noted earlier, randomRs runs in constant space in 6.6.


Thanks
Ian


--- End Message ---

Reply via email to