How to fix “Allocation failed - JavaScript heap out of memory”?
12.16.3
Hello everybody, been struggling for weeks trying to figure out a solution pour my problem, but unfortunately nothing been found helpful
Deprite the fact I increased the memory ---max-old-space-size=3072 i keep receiving about 30 reports a day, and this causes a regular 502 errors.
Bellow is one of the latest reports. Do you please have an idea how to permanently solve this?
Thanks
{ "header": { "reportVersion": 2, "event": "Allocation failed - JavaScript heap out of memory", "trigger": "FatalError", "filename": "report.20200501.140308.24618.0.001.json", "dumpEventTime": "2020-05-01T14:03:08Z", "dumpEventTimeStamp": "1588334588800", "processId": 24618, "threadId": null, "cwd": "/home/site", "commandLine": [ "node", "/home/site/node_modules/.bin/nuxt", "start", "---max-old-space-size=3072" ], "nodejsVersion": "v12.16.2", "glibcVersionRuntime": "2.17", "glibcVersionCompiler": "2.17", "wordSize": 64, "arch": "x64", "platform": "linux", "componentVersions": { "node": "12.16.2", "v8": "7.8.279.23-node.34", "uv": "1.34.2", "zlib": "1.2.11", "brotli": "1.0.7", "ares": "1.15.0", "modules": "72", "nghttp2": "1.40.0", "napi": "5", "llhttp": "2.0.4", "http_parser": "2.9.3", "openssl": "1.1.1e", "cldr": "36.0", "icu": "65.1", "tz": "2019c", "unicode": "12.1" }, "release": { "name": "node", "lts": "Erbium", "headersUrl": "https://nodejs.org/download/release/v12.16.2/node-v12.16.2-headers.tar.gz", "sourceUrl": "https://nodejs.org/download/release/v12.16.2/node-v12.16.2.tar.gz" }, "osName": "Linux", "osRelease": "3.10.0-1062.18.1.el7.x86_64", "osVersion": "#1 SMP Tue Mar 17 23:49:17 UTC 2020", "osMachine": "x86_64", "cpus": [ { "model": "Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz", "speed": 2095, "user": 608886800, "nice": 19400, "sys": 66939700, "idle": 8241365000, "irq": 0 }, { "model": "Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz", "speed": 2095, "user": 614711000, "nice": 10200, "sys": 68079900, "idle": 8241099100, "irq": 0 }, { "model": "Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz", "speed": 2095, "user": 612194500, "nice": 11400, "sys": 67620700, "idle": 8244685800, "irq": 0 }, { "model": "Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz", "speed": 2095, "user": 610967400, "nice": 16400, "sys": 67288400, "idle": 8236352200, "irq": 0 } ], "networkInterfaces": [ { "name": "lo", "internal": true, "mac": "00:00:00:00:00:00", "address": "127.0.0.1", "netmask": "255.0.0.0", "family": "IPv4" }, { "name": "eth0", "internal": false, "mac": "00:0d:3a:89:b1:dd", "address": "10.168.0.36", "netmask": "255.255.255.224", "family": "IPv4" }, { "name": "lo", "internal": true, "mac": "00:00:00:00:00:00", "address": "::1", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "scopeid": 0 }, { "name": "eth0", "internal": false, "mac": "00:0d:3a:89:b1:dd", "address": "fe80::20d:3aff:fe89:b1dd", "netmask": "ffff:ffff:ffff:ffff::", "family": "IPv6", "scopeid": 2 } ], "host": "server-front-01" }, "javascriptStack": { "message": "No stack.", "stack": [ "Unavailable." ] }, "nativeStack": [ { "pc": "0x0000000000b40285", "symbol": "report::TriggerNodeReport(v8::Isolate*, node::Environment*, char const*, char const*, std::string const&, v8::Local<v8::String>) [node]" }, { "pc": "0x0000000000a033ef", "symbol": "node::OnFatalError(char const*, char const*) [node]" }, { "pc": "0x0000000000b76ffe", "symbol": "v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]" }, { "pc": "0x0000000000b77379", "symbol": "v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]" }, { "pc": "0x0000000000d23ad5", "symbol": " [node]" }, { "pc": "0x0000000000d24166", "symbol": "v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]" }, { "pc": "0x0000000000d309e5", "symbol": "v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]" }, { "pc": "0x0000000000d31895", "symbol": "v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]" }, { "pc": "0x0000000000d3434c", "symbol": "v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]" }, { "pc": "0x0000000000cfaf1b", "symbol": "v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]" }, { "pc": "0x000000000103d85e", "symbol": "v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]" }, { "pc": "0x00000000013c03d9", "symbol": " [node]" } ], "javascriptHeap": { "totalMemory": 2154131456, "totalCommittedMemory": 2150574192, "usedMemory": 2133094032, "availableMemory": 48816936, "memoryLimit": 2197815296, "heapSpaces": { "read_only_space": { "memorySize": 262144, "committedMemory": 33088, "capacity": 32808, "used": 32808, "available": 0 }, "new_space": { "memorySize": 4194304, "committedMemory": 1211336, "capacity": 2094912, "used": 192400, "available": 1902512 }, "old_space": { "memorySize": 2132156416, "committedMemory": 2131969496, "capacity": 2117872976, "used": 2116737304, "available": 1135672 }, "code_space": { "memorySize": 5410816, "committedMemory": 5253056, "capacity": 4831296, "used": 4831296, "available": 0 }, "map_space": { "memorySize": 5509120, "committedMemory": 5508560, "capacity": 4811840, "used": 4811840, "available": 0 }, "large_object_space": { "memorySize": 5976064, "committedMemory": 5976064, "capacity": 5943840, "used": 5943840, "available": 0 }, "code_large_object_space": { "memorySize": 622592, "committedMemory": 622592, "capacity": 544544, "used": 544544, "available": 0 }, "new_large_object_space": { "memorySize": 0, "committedMemory": 0, "capacity": 2094912, "used": 0, "available": 2094912 } } }, "resourceUsage": { "userCpuSeconds": 406.194, "kernelCpuSeconds": 13.5663, "cpuConsumptionPercent": 21.1573, "maxRss": 2278514688, "pageFaults": { "IORequired": 0, "IONotRequired": 1696633 }, "fsActivity": { "reads": 0, "writes": 0 } }, "uvthreadResourceUsage": { "userCpuSeconds": 161.215, "kernelCpuSeconds": 7.10867, "cpuConsumptionPercent": 8.48407, "fsActivity": { "reads": 0, "writes": 0 } }, "libuv": [ ], "workers": [ ], "environmentVariables": { "npm_config_save_dev": "", "npm_config_legacy_bundling": "", "npm_config_dry_run": "", "npm_config_viewer": "man", "npm_config_only": "", "npm_config_commit_hooks": "true", "npm_config_browser": "", "npm_package_devDependencies_prettier": "^1.18.2", "npm_config_also": "", "npm_package_dependencies_vueperslides": "^1.17.4", "npm_config_sign_git_commit": "", "npm_config_rollback": "true", "NODE": "/usr/bin/node", "npm_config_usage": "", "npm_config_audit": "true", "INIT_CWD": "/home/site", "npm_package_dependencies_axios": "^0.19.0", "npm_config_globalignorefile": "/usr/etc/npmignore", "npm_package_dependencies_stylelint_scss": "^3.12.1", "SHELL": "/bin/bash", "npm_config_shell": "/bin/bash", "npm_config_maxsockets": "50", "npm_config_init_author_url": "", "npm_package_devDependencies_style_loader": "^0.23.1", "npm_package_dependencies_browser_cookies": "^1.2.0", "npm_config_shrinkwrap": "true", "npm_config_parseable": "", "npm_config_metrics_registry": "https://registry.npmjs.org/", "npm_config_timing": "", "npm_config_init_license": "ISC", "npm_package_dependencies__nuxtjs_axios": "^5.3.6", "npm_package_scripts_lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "npm_config_if_present": "", "npm_package_dependencies_cookieparser": "^0.1.0", "npm_package_dependencies_browserslist": "^4.11.1", "npm_package_dependencies__nuxtjs_device": "^1.2.6", "npm_package_scripts_dev": "nuxt dev", "npm_config_sign_git_tag": "", "npm_config_init_author_email": "", "npm_config_cache_max": "Infinity", "npm_config_preid": "", "npm_config_long": "", "npm_config_local_address": "", "npm_config_git_tag_version": "true", "npm_config_cert": "", "npm_package_devDependencies_webpack_bundle_analyzer": "^3.3.2", "npm_package_dependencies_superagent": "^3.8.3", "npm_config_registry": "https://registry.npmjs.org/", "npm_config_noproxy": "", "npm_config_fetch_retries": "2", "npm_package_private": "true", "npm_package_devDependencies_extract_text_webpack_plugin": "^3.0.2", "npm_package_dependencies_nuxt_trailingslash_module": "^1.1.0", "npm_package_scripts_generate": "nuxt generate", "npm_config_versions": "", "npm_config_message": "%s", "npm_config_key": "", "npm_package_readmeFilename": "README.md", "npm_package_dependencies_regenerator_runtime": "^0.13.5", "npm_package_dependencies_vue_content_loader": "^0.2.2", "npm_package_description": "Site", "USER": "site", "npm_package_devDependencies_glob_all": "^3.2.1", "npm_package_devDependencies_eslint_loader": "^1.9.0", "npm_package_dependencies_intersection_observer": "^0.7.0", "npm_package_dependencies__nuxtjs_pwa": "^3.0.0-beta.20", "npm_package_dependencies__nuxtjs_dotenv": "^1.3.0", "npm_config_globalconfig": "/usr/etc/npmrc", "npm_package_devDependencies_eslint_friendly_formatter": "^3.0.0", "npm_package_dependencies__nuxtjs_sentry": "^3.0.1", "npm_config_prefer_online": "", "npm_config_logs_max": "10", "npm_config_always_auth": "", "npm_package_devDependencies__nuxtjs_vuetify": "^1.3.2", "npm_package_devDependencies_eslint": "^4.19.1", "npm_package_dependencies__nuxtjs_proxy": "^1.3.1", "npm_execpath": "/usr/lib/node_modules/npm/bin/npm-cli.js", "npm_config_global_style": "", "npm_config_cache_lock_retries": "10", "npm_package_dependencies_svgxuse": "^1.2.6", "npm_package_dependencies_node_fetch": "^2.6.0", "npm_config_update_notifier": "true", "npm_config_cafile": "", "npm_package_dependencies_vue_authenticate": "^1.4.1", "npm_package_dependencies_vue_googlemaps": "^0.1.2", "npm_package_author_name": "Site", "npm_config_heading": "npm", "npm_config_audit_level": "low", "npm_package_devDependencies_eslint_plugin_prettier": "^3.1.1", "npm_config_searchlimit": "20", "npm_config_read_only": "", "npm_config_offline": "", "npm_config_fetch_retry_mintimeout": "10000", "npm_config_json": "", "npm_config_access": "", "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"start\"],\"original\":[\"run\",\"start\"]}", "npm_package_dependencies_vue_menu_aim": "^1.2.0", "npm_package_dependencies_atob": "^2.1.1", "PATH": "/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/site/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin", "npm_config_allow_same_version": "", "NODE_PORT": "3010", "npm_config_https_proxy": "", "npm_config_engine_strict": "", "npm_config_description": "true", "npm_package_dependencies_vue": "^2.6.11", "npm_config_userconfig": "/home/site/.npmrc", "npm_config_init_module": "/home/site/.npm-init.js", "PWD": "/home/site", "npm_config_cidr": "", "npm_package_devDependencies__nuxtjs_laravel_echo": "^1.0.2", "npm_config_user": "", "npm_config_node_version": "12.16.2", "npm_lifecycle_event": "start", "npm_config_save": "true", "npm_config_ignore_prepublish": "", "npm_config_editor": "vi", "npm_config_auth_type": "legacy", "npm_package_name": "site", "LANG": "en_US.UTF-8", "npm_config_tag": "latest", "npm_config_script_shell": "", "npm_package_dependencies_universal_cookie": "^3.0.7", "npm_config_progress": "true", "npm_config_global": "", "npm_config_before": "", "npm_package_scripts_start": "nuxt start ---max-old-space-size=3072", "npm_package_scripts_build": "nuxt build", "npm_config_searchstaleness": "900", "npm_config_optional": "true", "npm_config_ham_it_up": "", "npm_package_dependencies_vue_script2": "^2.1.0", "npm_config_save_prod": "", "npm_config_force": "", "npm_config_bin_links": "true", "npm_package_dependencies_vee_validate": "^2.1.7", "npm_config_searchopts": "", "npm_package_dependencies_vuetify": "^2.2.11", "npm_package_dependencies_superagent_use": "^0.1.0", "npm_config_node_gyp": "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js", "npm_config_depth": "Infinity", "npm_package_devDependencies_svg_spritemap_webpack_plugin": "^3.3.1", "npm_package_devDependencies_eslint_config_prettier": "^6.4.0", "npm_package_dependencies_vue_i18n": "^7.6.0", "npm_config_sso_poll_frequency": "500", "npm_config_rebuild_bundle": "true", "npm_package_version": "1.1.0", "npm_config_unicode": "true", "SHLVL": "1", "npm_package_dependencies_vuetify_loader": "^1.3.0", "HOME": "/home/site/", "npm_config_fetch_retry_maxtimeout": "60000", "npm_package_devDependencies_eslint_plugin_vue": "^4.7.1", "npm_config_tag_version_prefix": "v", "npm_config_strict_ssl": "true", "npm_config_sso_type": "oauth", "npm_config_scripts_prepend_node_path": "warn-only", "npm_config_save_prefix": "^", "npm_config_loglevel": "notice", "npm_config_ca": "", "npm_package_devDependencies_prettier_eslint": "^9.0.0", "npm_package_dependencies_stylelint": "^11.1.1", "npm_package_dependencies_dotenv": "^6.2.0", "npm_config_save_exact": "", "npm_config_group": "10002", "npm_config_fetch_retry_factor": "10", "npm_config_dev": "", "npm_package_devDependencies_cross_env": "^5.2.0", "npm_package_devDependencies_babel_eslint": "^8.2.6", "npm_config_version": "", "npm_config_prefer_offline": "", "npm_config_cache_lock_stale": "60000", "npm_package_dependencies_nuxt_i18n": "^6.4.1", "npm_package_dependencies_js_cookie": "^2.2.0", "npm_config_otp": "", "npm_config_cache_min": "10", "npm_package_dependencies_caniuse_lite": "^1.0.30001039", "npm_config_searchexclude": "", "npm_config_cache": "/home/site/.npm", "npm_package_dependencies_vue_server_renderer": "^2.6.11", "npm_package_dependencies_sass_loader": "^7.1.0", "LOGNAME": "site", "npm_lifecycle_script": "nuxt start ---max-old-space-size=3072", "npm_config_color": "true", "npm_package_devDependencies_babel_plugin_transform_imports": "^1.5.0", "npm_config_proxy": "", "npm_config_package_lock": "true", "npm_config_package_lock_only": "", "npm_config_fund": "true", "npm_config_save_optional": "", "npm_package_dependencies_sass": "^1.22.9", "npm_config_ignore_scripts": "", "npm_config_user_agent": "npm/6.14.4 node/v12.16.2 linux x64", "npm_config_cache_lock_wait": "10000", "npm_config_production": "", "npm_package_dependencies_nuxt": "^2.12.2", "npm_config_send_metrics": "", "npm_config_save_bundle": "", "npm_config_umask": "0022", "npm_config_node_options": "", "npm_config_init_version": "1.0.0", "npm_package_devDependencies_raw_loader": "^4.0.0", "npm_package_dependencies_vue_template_compiler": "^2.6.11", "npm_config_init_author_name": "", "npm_config_git": "git", "npm_config_scope": "", "npm_package_devDependencies_css_loader": "^3.2.0", "npm_config_unsafe_perm": "true", "npm_config_tmp": "/tmp", "npm_config_onload_script": "", "npm_package_scripts_precommit": "npm run lint", "npm_package_scripts_stylelint": "stylelint '**/*.scss' --syntax scss --fix", "npm_node_execpath": "/usr/bin/node", "npm_config_prefix": "/usr", "npm_config_link": "", "npm_config_format_package_lock": "true", "_": "/home/site/node_modules/.bin/nuxt", "NODE_ENV": "production", "API_URL": "https://api.site.com", "CDN": "https://cdn.site.com", "PORT": "3010", "HTTP": "https://", "SENTRY_DSN": "https://[email protected]/1890076", "PAYLINE_CSS": "https://payment.payline.com/styles/widget-min.css", "PAYLINE_JS": "https://payment.payline.com/scripts/widget-min.js", "_AXIOS_BASE_URL_": "https://api.site.com", "VUE_ENV": "server" }, "userLimits": { "core_file_size_blocks": { "soft": 0, "hard": "unlimited" }, "data_seg_size_kbytes": { "soft": "unlimited", "hard": "unlimited" }, "file_size_blocks": { "soft": "unlimited", "hard": "unlimited" }, "max_locked_memory_bytes": { "soft": 65536, "hard": 65536 }, "max_memory_size_kbytes": { "soft": "unlimited", "hard": "unlimited" }, "open_files": { "soft": 4096, "hard": 4096 }, "stack_size_bytes": { "soft": 8388608, "hard": "unlimited" }, "cpu_time_seconds": { "soft": "unlimited", "hard": "unlimited" }, "max_user_processes": { "soft": 31774, "hard": 31774 }, "virtual_memory_kbytes": { "soft": "unlimited", "hard": "unlimited" } }, "sharedObjects": [ "/lib64/libdl.so.2", "/lib64/libstdc++.so.6", "/lib64/libm.so.6", "/lib64/libgcc_s.so.1", "/lib64/libpthread.so.0", "/lib64/libc.so.6", "/lib64/ld-linux-x86-64.so.2", "/lib64/libnss_files.so.2", "/lib64/libnss_dns.so.2", "/lib64/libresolv.so.2" ] }
Do you please have an idea how to permanently solve this?
The easiest way is to share all your relevant scripts and someone can look at them and tell you exactly what the problem is. How do you expect any help if you don't show your code? Or, if your scripts are closed-source, feel free to pay a professional developer to solve the problem for you.
Thank you Thomas for your reply.
I dont know what code to show you, the whole app is finished and there is plenty of code.
I posted this issue thinking that you may have some tips or advices, If increasing the memory the way i did in nuxt.config.js helps:
"scripts": { "dev": "nuxt dev", "build": "nuxt build", "start": "nuxt start ---max-old-space-size=4096", "generate": "nuxt generate", "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", "stylelint": "stylelint '**/*.scss' --syntax scss --fix", "precommit": "npm run lint" },
Also was wondering if with your experience you may be able to directly tell what need to be changed/ improved to fix this problem...
Thanks
I dont know what code to show you, the whole up is finished and there is plenty of code.
Create a new github repository and upload the entire project. Otherwise, there is no way for anyone to tell you exactly what the problem is.
I posted this issue thinking that you may have some tips or advices
See if https://github.com/nodejs/help/issues/1377#issuecomment-404208906 can help you.
OK thanks, I'll see what I can do and will keep you posted. Is it recommended to start using nodeJs v14 in a production website? does it have any performance improvements?
Cheers
check this answer: https://stackoverflow.com/questions/38558989/node-js-heap-out-of-memory/66914674#66914674
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.