Getting used and available memory

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

Getting used and available memory

Mads Lindstrøm-2
Hi

I have tried haskell.org, Google and Hoolge, but I cannot find any
function to give me the available and/or used memory of a Haskell
program. Is it just not there? Or am I missing it somehow?


/Mads


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

Re: Getting used and available memory

Daniel Peebles
It's not an easy measurement to even define. There was a huge debacle recently about a windows program that reported misleading numbers about used memory. The fact that GHC has its own allocator and "hogs" OS memory (it never returns it to the OS) might complicate the definition further. But in general, if you're looking for an OS-level measure you're probably going to need to go to the FFI and talk to the specific OS's API for the task. I'm not sure if the GHC runtime allows you to ask much about allocated memory. The only thing I've done with it was FFI out to a variable that counts the number of bytes allocated to measure allocations in calls like GHCi does. 

On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm <[hidden email]> wrote:
Hi

I have tried haskell.org, Google and Hoolge, but I cannot find any
function to give me the available and/or used memory of a Haskell
program. Is it just not there? Or am I missing it somehow?


/Mads


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


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

Re: Getting used and available memory

Mads Lindstrøm-2
Hi

I was _not_ looking for the OS-level measure, but rather something
reported by the run-time. Thanks you for the answer anyway.

/Mads

On Tue, 2010-04-27 at 15:32 -0400, Daniel Peebles wrote:

> It's not an easy measurement to even define. There was a huge debacle
> recently about a windows program that reported misleading numbers
> about used memory. The fact that GHC has its own allocator and "hogs"
> OS memory (it never returns it to the OS) might complicate the
> definition further. But in general, if you're looking for an OS-level
> measure you're probably going to need to go to the FFI and talk to the
> specific OS's API for the task. I'm not sure if the GHC runtime allows
> you to ask much about allocated memory. The only thing I've done with
> it was FFI out to a variable that counts the number of bytes allocated
> to measure allocations in calls like GHCi does.
>
> On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm
> <[hidden email]> wrote:
>         Hi
>        
>         I have tried haskell.org, Google and Hoolge, but I cannot find
>         any
>         function to give me the available and/or used memory of a
>         Haskell
>         program. Is it just not there? Or am I missing it somehow?
>        
>        
>         /Mads
>        
>        
>         _______________________________________________
>         Haskell-Cafe mailing list
>         [hidden email]
>         http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

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

Re: Getting used and available memory

Don Stewart-2
We could bind to Rts.c in the GHC runtime, and get all the stats
programmatically that you can get with +RTS -s

mads.lindstroem:

> Hi
>
> I was _not_ looking for the OS-level measure, but rather something
> reported by the run-time. Thanks you for the answer anyway.
>
> /Mads
>
> On Tue, 2010-04-27 at 15:32 -0400, Daniel Peebles wrote:
> > It's not an easy measurement to even define. There was a huge debacle
> > recently about a windows program that reported misleading numbers
> > about used memory. The fact that GHC has its own allocator and "hogs"
> > OS memory (it never returns it to the OS) might complicate the
> > definition further. But in general, if you're looking for an OS-level
> > measure you're probably going to need to go to the FFI and talk to the
> > specific OS's API for the task. I'm not sure if the GHC runtime allows
> > you to ask much about allocated memory. The only thing I've done with
> > it was FFI out to a variable that counts the number of bytes allocated
> > to measure allocations in calls like GHCi does.
> >
> > On Tue, Apr 27, 2010 at 12:01 PM, Mads Lindstrøm
> > <[hidden email]> wrote:
> >         Hi
> >        
> >         I have tried haskell.org, Google and Hoolge, but I cannot find
> >         any
> >         function to give me the available and/or used memory of a
> >         Haskell
> >         program. Is it just not there? Or am I missing it somehow?
> >        
> >        
> >         /Mads
> >        
> >        
> >         _______________________________________________
> >         Haskell-Cafe mailing list
> >         [hidden email]
> >         http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Getting used and available memory

Bernie Pope-2
On 27 April 2010 17:55, Don Stewart <[hidden email]> wrote:
> We could bind to Rts.c in the GHC runtime, and get all the stats
> programmatically that you can get with +RTS -s

A long time ago I made a simple binding which has been packaged for
cabal by Gwern Branwen. The package is called highWaterMark:

   http://hackage.haskell.org/package/highWaterMark

As the name suggests it tells you the upper limit of RTS allocated
memory. It does not tell you about memory allocated by foreign calls.

I can't test it at the moment, but it is probably bit-rotten.

Maybe it is something to start with?

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

Re: Getting used and available memory

Mads Lindstrøm-2
In reply to this post by Don Stewart-2
Hi

On Tue, 2010-04-27 at 14:55 -0700, Don Stewart wrote:
> We could bind to Rts.c in the GHC runtime, and get all the stats
> programmatically that you can get with +RTS -s

That would be nice.


/Mads

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