9

How to see memory usage in a Laravel app? This is for testing and to approximate how much server memory (RAM) resource I need to setup for my server usage assumptions.

doncadavona
  • 7,162
  • 9
  • 41
  • 54

1 Answers1

14

To see a Laravel app's memory usage, install Laravel Debugbar.

This is the easiest way to track a Laravel app's memory usage and many other things like database queries, requests, durations, exceptions etc. Saves you time from reading lots of configs, codes and other workarounds found online.

Here, a fresh Laravel 5.5 app uses 3.73MB of memory: enter image description here

(may vary or fluctuate around 3.75MB)

Douwe de Haan
  • 6,247
  • 1
  • 30
  • 45
doncadavona
  • 7,162
  • 9
  • 41
  • 54
  • Add anything and that will significantly rise. Laravel / PHP is great, although compared to node / express its memory hungry. – AndrewMcLagan May 27 '19 at 23:44
  • 1
    @AndrewMcLagan Comparing Laravel to Express doesn't really make sense because the latter includes a friction of what Laravel includes out of the box. You can compare Symfony to Express if you want to see somewhat more relevant results. – andonovn May 29 '20 at 11:02
  • @andonovn Very true. Also I dont think memory should really be a reason one considers which language / framework to choose. That would be working backwards. – AndrewMcLagan Jun 01 '20 at 08:03
  • Using this technique to check the memory for Laravel 8.x and 9.x shows 5MB on first load, and 1MB for subsequent loads (in PHP 8.1). – earboxer Oct 27 '22 at 19:29