-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Would it be possible to include the memory used by the function in the context object ?
https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/doc_source/nodejs-context.md
This is ultimately outputted in the cloudwatch log; but having a getter for the current usage similar to ( getRemainingTimeInMillis ) would be of great value. Today there is process.memoryUsage()
that does not appear to have a 1 to 1 mapping of what AWS assesses in the end:
For example:
const used = process.memoryUsage();
let totalUsed = 0;
for (let key in used) {
const mb = Math.round(used[key] / 1024 / 1024 * 100) / 100;
totalUsed+=mb;
console.log(`${key} ${mb} MB`);
}
console.log("total: ", totalUsed)
callback(null, response.ok(result) );
log:
2020-08-01T18:46:02.291Z * INFO rss 47.01 MB
2020-08-01T18:46:02.291Z * INFO heapTotal 15.92 MB
2020-08-01T18:46:02.292Z * INFO heapUsed 7.58 MB
2020-08-01T18:46:02.292Z * INFO external 1.52 MB
2020-08-01T18:46:02.292Z * INFO arrayBuffers 0.24 MB
2020-08-01T18:46:02.292Z * INFO total: 72.27
END RequestId: *
REPORT RequestId:*Duration: 1188.30 ms Billed Duration: 1200 ms Memory Size: 128 MB Max Memory Used: 81 MB Init Duration: 236.17 ms
Metadata
Metadata
Assignees
Labels
No labels