Returns the total memory usage from all samples taken by comparing
each sample to the base memory sample.

@return integer
Memory usage in bytes.
552639
public function retrieveTotalMemoryUsage()
    {
        $base = $this->retrieve(0);
        $total = $last = 0;

        foreach ($this->retrieve() as $item) {
            $total += max(0, (($item[5]-$base[5]) - $last));
            $last = $item[5]-$base[5];
        }

        return $total;
    }
699169
protected function process_memory_info()
    {

        $this->current_mem_use     = (int)memory_get_usage();
        $this->current_mem_peak    = (int)memory_get_peak_usage();
        $this->current_mem_peak_mb = (float)$this->current_mem_peak / 1024 / 1024;
        $this->current_mem_use_mb  = (float)$this->current_mem_use / 1024 / 1024;

        return true;
    }
1188778
private function checkMemory() {
		list($imgWidth, $imgHeight) = getimagesize($this->dir . $this->filename);
		$imgMemory = $imgWidth * $imgHeight * parent::BYTES_PER_PIXEL;
		$memoryLimit = ini_get('memory_limit');
		//FIXME dont assume memorylimit is in mb
		$availableMemory = (int)$memoryLimit * parent::BYTES_PER_MB;

		if($imgMemory > $availableMemory) {
			throw new RuntimeException("Image size exceeds memory limit: {$imgWidth}x{$imgHeight} = {$imgMemory} bytes, {$availableMemory} bytes available");
		}
		
		return true;
	}
387312
@Override
    public int getInMemoryDataSize()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getInMemoryDataSize");

        JsMessage localMsg = getJSMessage(true);
        int msgSize = localMsg.getInMemorySize();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getInMemoryDataSize", Integer.valueOf(msgSize));

        return msgSize;
    }
264220
public function memoryUsage()
    {
        if ($this->getMemoryLimit()) {
            $remaining = (memory_get_peak_usage() - memory_get_usage());

            $left = (memory_get_peak_usage() + $remaining);

            if ($left < memory_get_peak_usage(true)) {
                $translateError = $this->translate->translate(
                    'PHP Ran Out of Memory. Please Try Again',
                    'mp3'
                );

                $location = $this->serverUrl
                    ->get('url')
                    ->__invoke(
                        'mp3-search',
                        [
                            'flash' => $translateError
                        ]
                    );

                header('Location: ' . $location);

                exit;
            }
        }
    }
659644
@Override
  public final void sample()
  {
    long totalCount = _totalCount.get();
    long lastTotal = _lastTotal;
    _lastTotal = totalCount;

    _value = totalCount - lastTotal;
  }
96607
public static int getTotalPhysicalMemorySizeInMB() {

    int memorySizeInMB;
    try {
      long memorySizeInBytes = ((com.sun.management.OperatingSystemMXBean) ManagementFactory
                    .getOperatingSystemMXBean()).getTotalPhysicalMemorySize();

      memorySizeInMB = (int) (memorySizeInBytes / BYTES_IN_MEGABYTE);
    } catch (Exception e) {
      memorySizeInMB = -1;
    }

    return memorySizeInMB;
  }
1195406
public static String memoryUsage() {
    final Runtime runtime = Runtime.getRuntime();

    runtime.gc();

    final long max = runtime.maxMemory();
    final long total = runtime.totalMemory();
    final long free = runtime.freeMemory();
    final long used = total - free;

    return String.format("%d\t%d\t%d\t%d", max, total, free, used);
  }
893266
public function calcResourceMemorySize(): int {
		$imageData = getimagesize($this->filePath);
		$mb = 1048576;  // number of bytes in 1M
		$k64 = 65536;	// number of bytes in 64K
		$tweakfactor = 1.62;
		return round(( $imageData[0] * $imageData[1] * $imageData['bits'] * $imageData['channels'] / 8 + $k64) * $tweakfactor);
	}
462800
public function memory()
	{
		$memory = $this->memory;

		foreach ($this->marks as $mark)
		{
			if ($mark->memory() > $memory)
			{
				$memory = $mark->memory();
			}
		}

		return $memory;
	}
1104588
public function getMemoryUsage()
    {
        if (empty($this->endMemory)) {
            $this->stop();
        }

        return $this->getFormattedMemorySize($this->endMemory - $this->startMemory);
    }
502105
private long getTotalInternalMemorySize() {
        final File path = Environment.getDataDirectory();
        final StatFs stat = new StatFs(path.getPath());
        final long blockSize;
        final long totalBlocks;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            blockSize = stat.getBlockSizeLong();
            totalBlocks = stat.getBlockCountLong();
        } else {
            //noinspection deprecation
            blockSize = stat.getBlockSize();
            //noinspection deprecation
            totalBlocks = stat.getBlockCount();
        }
        return totalBlocks * blockSize;
    }
1296445
public function printMemoryUsageInfo()
    {
        if (null === $this->memoryBeforeTearDown) {
            throw new \BadMethodCallException('To use measurement features you need to call PHPUnit_Helper::measureMemoryBeforeTearDown() first.');
        }

        if (null === $this->memoryAfterTearDown) {
            $this->measureMemoryAfterTearDown();
        }

        printf("\n(Memory used before tearDown(): %s)", $this->formatMemory($this->memoryBeforeTearDown));
        printf("\n(Memory used after tearDown(): %s)", $this->formatMemory($this->memoryAfterTearDown));
        printf("\n(Memory saved with tearDown(): %s)\n", $this->formatMemory($this->memoryBeforeTearDown - $this->memoryAfterTearDown));
    }
64386
public function byteSize()
    {
        return mb_strlen($this->name) +
                mb_strlen($this->type) +
                mb_strlen($this->value);
    }
1268374
public long getKeyMemoryUsageBytes() {
    long total = 0;
    for (int i = 0; i < maps_.length; i++) {
      if (maps_[i] != null) {
        total += (long) (maps_[i].getActiveEntries()) * keySizeBytes_;
      }
    }
    return total;
  }
1322050
def get_memory_size(self):
        """"""
        n = sys.getsizeof(self)
        n += sys.getsizeof(self.padding)
        n += total_size(self.start_addr)
        n += total_size(self._buf)
        n += sys.getsizeof(self._offset)
        return n
530558
public function getInfo() {
		$info = $this->createInfoset();
		
		$memory = memory_get_peak_usage();
		$limit  = ini_get('memory_limit');
		
		if ($limit < 0) {
			$limit = 'unlimited';
		}
		
		$info->setIcon('chip')
		     ->setName('Memory usage')
		     ->setTitle($this->formatMemory($memory) . ' of ' . $limit);
		
		if ($limit / $memory < 0.25) {
			$info->setLevel(Infoset::LEVEL_WARNING);
		}
		
		return $info;
	}