Skip to content

Commit f2df554

Browse files
committed
Free autopipelining callbacks when they stop getting used.
Set kCallbacks field to null instead of the empty array because nothing should append to it until a new pipeline starts. If anything did, that is a bug. With Redis.Cluster, there could be 65536 different arrays pointing to callbacks that aren't needed.
1 parent 2ee877e commit f2df554

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/autoPipelining.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ function executeAutoPipeline(client, slotKey: string) {
4545
client._autoPipelines.delete(slotKey);
4646

4747
const callbacks = pipeline[kCallbacks];
48+
// Stop keeping a reference to callbacks immediately after the callbacks stop being used.
49+
// This allows the GC to reclaim objects referenced by callbacks, especially with 2^16 slots
50+
// in Redis.Cluster
51+
pipeline[kCallbacks] = null;
4852

4953
// Perform the call
5054
pipeline.exec(function (err, results) {

0 commit comments

Comments
 (0)