Skip to content

Commit 80d2be2

Browse files
Anonymous Function Reference Memory Leak (#20)
It seems that inside the checkQueue method, the anonymous function defined as the same name is causing a memory leak. If we forcefully set the variable to null when we will not be calling it recursively, it stops the memory leak from occurring.
1 parent 4658c6b commit 80d2be2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Discord/Bucket.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ public function checkQueue()
133133
}
134134
$this->logger->info($this.' expecting rate limit, timer interval '.($interval * 1000).' ms');
135135
$this->checkerRunning = false;
136+
$checkQueue = null;
136137

137138
return;
138139
}
139140

140141
// Queue is empty, job done.
141142
if ($this->queue->isEmpty()) {
142143
$this->checkerRunning = false;
144+
$checkQueue = null;
143145

144146
return;
145147
}
@@ -191,6 +193,8 @@ public function checkQueue()
191193
// Will be restarted when global rate-limit finished.
192194
else {
193195
$this->checkerRunning = false;
196+
$checkQueue = null;
197+
194198
$this->logger->debug($this.' stopping queue checker');
195199
}
196200
} else {

0 commit comments

Comments
 (0)