Hoa central
Static Public Member Functions | List of all members
Hoa\Memory\Memory Class Reference

Static Public Member Functions

static getUsage ($realUsage=false)
 
static getPeakUsage ($realUsage=false)
 
static setLimit ($size)
 
static getLimit ()
 
static getRUsage ($who=0)
 

Detailed Description

Class .

Work with memory.

Author
Ivan Enderlin ivan..nosp@m.ende.nosp@m.rlin@.nosp@m.hoa-.nosp@m.proje.nosp@m.ct.n.nosp@m.et

Definition at line 60 of file Memory.php.

Member Function Documentation

static Hoa\Memory\Memory::getLimit ( )
static

Get the memory limit.

public

Returns
mixed

Definition at line 112 of file Memory.php.

112  {
113 
114  return ini_get('memory_limit');
115  }
static Hoa\Memory\Memory::getPeakUsage (   $realUsage = false)
static

Get the peak of memory allocated by PHP.

public

Parameters
bool$realUsageSet this to true to get the real size of memory allocated from system; if not set or false, only the memory used by emalloc() is reported.
Returns
int

Definition at line 87 of file Memory.php.

87  {
88 
89  return memory_get_peak_usage($realUsage);
90  }
static Hoa\Memory\Memory::getRUsage (   $who = 0)
static

Get the current resource usages. Notes about returned array: it has the same indexes that the C structure rusage, i.e.: ru_utime.tv_usec => user time used (in seconds); ru_stime.tv_usec => system time used (in microseconds); ru_stime.tv_sec => system time used (in seconds); ru_maxrss => integral max resident set size; ru_ixrss => integral shared text memory size; ru_idrss => integral unshared data size; ru_isrss => integral unshared stack size; ru_minflt => page reclaims; ru_majflt => page faults; ru_nswap => swaps; ru_inblock => block input operations; ru_oublock => block output operations; ru_msgsnd => messages sent; ru_msgrcv => messages received; ru_nsignals => signals received; ru_nvcsw => voluntary context switches; ru_nivcsw => involuntary context switches.

Please, see your system's man page on getrusage(2) to get more informations. It is very interesting.

public

Parameters
int$whoIf set to 1, it will be called with RUSAGE_CHILDREN.
Returns
array
Exceptions

Definition at line 148 of file Memory.php.

148  {
149 
150  if(OS_WIN)
151  throw new Exception(
152  'Cannot get the current resource usages on Windows.', 0);
153 
154  return getrusage($who);
155  }
static Hoa\Memory\Memory::getUsage (   $realUsage = false)
static

Get the amount of memory allocated to PHP.

public

Parameters
bool$realUsageSet this to true to get the real size of memory allocated from system; if not set or false, only the memory used by emalloc() is reported.
Returns
int

Definition at line 72 of file Memory.php.

72  {
73 
74  return memory_get_usage($realUsage);
75  }
static Hoa\Memory\Memory::setLimit (   $size)
static

Set the memory limit.

public

Parameters
mixed$sizeIf an integer is given, the value is measured in bytes. If a string is given, it must be a shorthand notation (like '128M' for instance).
Returns
mixed

Definition at line 101 of file Memory.php.

101  {
102 
103  return ini_set('memory_limit', $size);
104  }

The documentation for this class was generated from the following file: