Skip to main content

Command Palette

Search for a command to run...

Optimizing Laravel's Memory Usage: Strategies to Clear Up Memory Issues

Updated
1 min read
Optimizing Laravel's Memory Usage: Strategies to Clear Up Memory Issues
M

Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).

In Laravel, you can clear the application's cache and free up memory by running a few commands. Here are the steps to clear Laravel's memory:

Clear the cache:

  • Open your command-line interface (CLI) or terminal.

  • Navigate to the root directory of your Laravel project.

  • Run the following command:

  •   php artisan cache:clear
    

Clear the view cache:

  • Run the following command:

  •   php artisan view:clear
    

Clear the route cache:

  • Run the following command:

  •   php artisan route:clear
    

Clear the configuration cache:

  • Run the following command:

  •   php artisan config:clear
    

Clear the compiled classes cache:

  • Run the following command:

  •   php artisan clear-compiled
    

Optionally, you can also optimize the application's autoloader:

  • Run the following command:

  •   composer dump-autoload --optimize