Created
April 26, 2023 11:07
-
-
Save mercuriete/302fb34ca5e52591601bd20303419b49 to your computer and use it in GitHub Desktop.
determine what memory limits you have on nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copied from https://stackoverflow.com/questions/73600496/heroku-node-js-app-allocation-failure-scavenge-might-not-succeed-with-memory-s | |
const v8 = require('v8'); | |
// added the code below to a route that caused a memory leak | |
const heapStats = v8.getHeapStatistics(); | |
const heapStatsMB = heapStats; | |
for (const key in heapStatsMB) { | |
heapStatsMB[key] = `${(((heapStatsMB[key] / 1024 / 1024) * 100) / 100).toFixed(2)} MB`; | |
} | |
console.table(heapStatsMB); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment