Where does memory go?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Where does memory go?

Joel Reymont
I compiled a simple one-liner: main = print "Blah".

This is the GC report:

       5,620 bytes allocated in the heap
           0 bytes copied during GC

           0 collections in generation 0 (  0.00s)
           0 collections in generation 1 (  0.00s)

           1 Mb total memory in use

Where did the memory go?

What is 5K and what is (more suprisingly) 1Mb?

        Thanks, Joel

--
http://wagerlabs.com/





_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Where does memory go?

Duncan Coutts
On Sun, 2006-01-08 at 17:01 +0000, Joel Reymont wrote:

> I compiled a simple one-liner: main = print "Blah".
>
> This is the GC report:
>
>        5,620 bytes allocated in the heap
>            0 bytes copied during GC
>
>            0 collections in generation 0 (  0.00s)
>            0 collections in generation 1 (  0.00s)
>
>            1 Mb total memory in use
>
> Where did the memory go?
>
> What is 5K and what is (more suprisingly) 1Mb?

At the most coarse level GHC's rts manages memory in 1Mb blocks so the
minimum amount of memory that ghc allocates for it's heap is 1Mb.

That doesn't mean that it uses all of that 1Mb so the VM system may not
need to dedicate the a whole 1Mb of actual RAM. Check with the OS to see
how much of each mapped area is actually resident.

Duncan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Where does memory go?

Bulat Ziganshin
In reply to this post by Joel Reymont
Hello Joel,

Sunday, January 08, 2006, 8:01:00 PM, you wrote:

JR> I compiled a simple one-liner: main = print "Blah".

JR>        5,620 bytes allocated in the heap

again, see at the GHC.Handle and so on :) try to find "print"
definition and manually substitute all the code generated by this
line. btw, one time i seen 15k raised (stripped) exefile just after
adding one line of code to Haskell app

--
Best regards,
 Bulat                            mailto:[hidden email]



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Where does memory go?

Simon Marlow
In reply to this post by Joel Reymont
Joel Reymont wrote:

> I compiled a simple one-liner: main = print "Blah".
>
> This is the GC report:
>
>       5,620 bytes allocated in the heap
>           0 bytes copied during GC
>
>           0 collections in generation 0 (  0.00s)
>           0 collections in generation 1 (  0.00s)
>
>           1 Mb total memory in use
>
> Where did the memory go?
>
> What is 5K and what is (more suprisingly) 1Mb?

Actually I'm surprised it's only 5k.  It's more like 30k here.

One reason for this allocation is that a buffer gets allocated for the
stdout Handle the first time something is written to it.

Cheers,
        Simon

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe