AWMS Lambda function terminates

I am executing lambda Nodejs function

which has the following configuration:

1) Maximum memory: 512MB

2) Standby time: 20 seconds

Memory consumption for one execution: 100 MB

One function requires 100 MB .

What I noticed:

When Lambda function

executed multiple times, the memory consumed continues to increase from 100MB to 128MB to 155MB , and so on ...

When it reaches the maximum memory ( 512MB ), execution stops and I get the following error:

Process completed before request completed

When you try a few minutes later, the memory is cleared and it goes out of 100 MB again

Is there a way to clear the used memory in a lambda function? If not, is there any other way to solve this problem?

EDIT:

I am using this lambda function to create an image from canvas

usingnode-canvas

+3


source to share


1 answer


I believe you may have some static variables. In a Java environment, AWS-Lambda stores static variables in memory when many lambda executions are executed. So, if you have a static map and you add variables to it with each lambda execution, it stays in memory. This can be the case for node.js too.



0


source







All Articles