Skip to content

Commit

Permalink
fix: free memory, empty lambda function pool
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Oct 10, 2022
1 parent f00383e commit b03cf79
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lambda/LambdaFunctionPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class LambdaFunctionPool {
// regardless of function processing time and e.g. user action (debugging)
this.#timerRef = setTimeout(() => {
// console.log('run cleanup')
this.#pool.forEach((lambdaFunctions) => {
this.#pool.forEach((lambdaFunctions, functionKey) => {
lambdaFunctions.forEach((lambdaFunction) => {
const { idleTimeInMillis, status } = lambdaFunction

Expand All @@ -40,6 +40,10 @@ export default class LambdaFunctionPool {
lambdaFunctions.delete(lambdaFunction)
}
})

if (lambdaFunctions.size === 0) {
this.#pool.delete(functionKey)
}
})

// schedule new timer
Expand Down

0 comments on commit b03cf79

Please sign in to comment.