---
title: "Discussion on \"Fix Laravel Eloquent Memory Leak with Large Datasets\" | Hashnode"
description: "Discussion on \"Fix Laravel Eloquent Memory Leak with Large Datasets\". Eloquent caches loaded relations on every Model instance, causing memory to climb in large loops. Call setRelations([]) on each iteration to release the cache."
url: "https://hashnode.com/posts/laravel-eloquent-memory-leak-1/69add98abc4378bf8e67b287"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Fix Laravel Eloquent Memory Leak with Large Datasets](https://recca0120.hashnode.dev/laravel-eloquent-memory-leak-1?utm_source=hashnode&utm_medium=feed)

Eloquent caches loaded relations on every Model instance, causing memory to climb in large loops. Call setRelations(\[\]) on each iteration to release the cache.

Mar 8 · 1 min read · recca0120.hashnode.dev  
Read the article

-   [#eloquent](https://hashnode.com/tag/eloquent)
-   [#laravel](https://hashnode.com/tag/laravel)
-   [#php](https://hashnode.com/tag/php)

## Written by

[recca0120](https://hashnode.com/@recca0120)

@recca0120 · Taipei, Taiwan

  
[View profile](https://hashnode.com/@recca0120)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
