How can I control memory usage in Perl on Solaris?

I want to track memory usage when starting a program in perl, so if the memory used by the current program is more than a threshold, I use approach A, otherwise I use approach B.

Does anyone have any ideas?

+3
source share
3 answers

I found this script from http://www.perlmonks.org/?node_id=235757 :

#!/usr/bin/perl  

use Proc::ProcessTable;  

sub memory_usage {  
  my $t = new Proc::ProcessTable;  
  foreach my $got ( @{$t->table} ) {  
    next if not $got->pid eq $$;  
    return $got->size;  
  }  
}  


print 'memory: '. memory_usage()/1024/1024 ."\n";  
+3
source

. Linux CPAN Sys::Statistics::Linux, /proc . , Solaris, Solaris::Procfs. Windows.

. Solaris, Solaris::Procfs.

+1
+1

Source: https://habr.com/ru/post/1759400/


All Articles