PHP code example of tkachikov / memory

1. Go to this page and download the library: Download tkachikov/memory library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tkachikov / memory example snippets

sh
// Create class
$memory = new Memory();

// Example memory usage: 2 MB
$usage = $memory->showUsage();

// Exmaple memory peak: 4 MB
$peak = $memory->showPeak();

// Get custom view memory
$customMemory = (new Memory()) // or in Laravel app(Memory::class)
  ->size(memory_get_usage(true))
  ->show();

// Reset peak memory (work on php 8.2)
$memory->reset();