Re: Debugging memory allocation

[prev] [thread] [next] [Date index for 2005/05/10]

From: Igor Chudov
Subject: Re: Debugging memory allocation
Date: 21:03 on 10 May 2005
I already have a function to get memory usage,
borrowed from Zpache::SizeLimit and modified.

sub linux_memory_size {
  my($size, $resident, $share) = (0, 0, 0);
  
  my $file = "/proc/self/statm";
  if (open my $fh, "<$file") {
    ($size, $resident, $share) = split /\s/, scalar
<$fh>;
    close $fh;
  } else {
    error_log("Fatal Error: couldn't access $file");
  }
  
  # linux on intel x86 has 4KB page size...
  #return ($size * 4, $share * 4);
  
  return $size * 4;
}
--- David Nicol <davidnicol@xxxxx.xxx> wrote:

> On 5/10/05, Igor Chudov <ichudov@xxxxx.xxx> wrote:
> > LogHandler seems
> > like such a place.
> 
> Undoubtably.  But how do you get the memory usage?
> read /proc/$$/mem or
> something? there is not, AFAICTFRAQG (as far as I
> can tell from recollection
> and quick googling) a line noise variable for
> current memory usage, and cpan
> only has a procfs module defined for Solaris.  So
> the question remains, after
> choosing loghandler as the way to write to the log,
> how to get the memory
> usage information?  Is there a better way than ps in
> backticks?
> Proc::ProcessTable
> might be the thing -- it appears to reimplement ps
> with the output as
> a perl data
> structure rather than linefeed-separated records. 
> There is also Unix::Process,
> but that is merely a wrapper  for ps in backticks.
> 


- Igor


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

(message missing)

Debugging memory allocation
Igor Chudov 17:24 on 09 May 2005

Re: Debugging memory allocation
Sam Tregar 18:46 on 09 May 2005

Re: Debugging memory allocation
Perrin Harkins 18:52 on 09 May 2005

Re: Debugging memory allocation
Igor Chudov 19:32 on 10 May 2005

Re: Debugging memory allocation
David Nicol 19:51 on 10 May 2005

Re: Debugging memory allocation
Igor Chudov 19:54 on 10 May 2005

Re: Debugging memory allocation
David Nicol 20:59 on 10 May 2005

Re: Debugging memory allocation
Igor Chudov 21:03 on 10 May 2005

Re: Debugging memory allocation
Stas Bekman 20:26 on 10 May 2005

Re: Debugging memory allocation
Perrin Harkins 21:01 on 10 May 2005

Generated at 15:53 on 25 May 2005 by mariachi v0.52