Hello Everyone,
I am trying to deploy app build with NestJs
for the Backend and ReactJs & ViteJs
for the FrontEnd.
The app is on Github
and i am using the repository directly in the app project.
During Build and Deploy, build complete, but while starting the server app it was giving me the following error.
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Here is the full logs after build completed
[2024-09-06 12:52:50] ✔ build complete
[2024-09-06 12:53:40] > omni-crm-server@1.0.0 start
[2024-09-06 12:53:40] > nest start
[2024-09-06 12:53:40]
[2024-09-06 12:54:01]
[2024-09-06 12:54:01] <--- Last few GCs --->
[2024-09-06 12:54:01]
[2024-09-06 12:54:01] [17:0x56bae10] 20102 ms: Mark-Compact (reduce) 509.2 (521.4) -> 508.7 (519.2) MB, 601.25 / 0.00 ms (+ 7.0 ms in 10 steps since start of marking, biggest step 1.5 ms, walltime since start of marking 612 ms) (average mu = 0.256, current mu = 0.238) fina[17:0x56bae10] 20106 ms: Scavenge 509.9 (519.2) -> 509.2 (522.2) MB, 1.16 / 0.00 ms (average mu = 0.256, current mu = 0.238) allocation failure;
[2024-09-06 12:54:01]
[2024-09-06 12:54:01]
[2024-09-06 12:54:01] <--- JS stacktrace --->
[2024-09-06 12:54:01]
[2024-09-06 12:54:01] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[2024-09-06 12:54:01] ----- Native stack trace -----
[2024-09-06 12:54:01]
[2024-09-06 12:54:01] 1: 0xb86ecf node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
[2024-09-06 12:54:01] 2: 0xef74d0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
[2024-09-06 12:54:01] 3: 0xef77b7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
[2024-09-06 12:54:01] 4: 0x1109355 [node]
[2024-09-06 12:54:01] 5: 0x11098e4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
[2024-09-06 12:54:01] 6: 0x11207d4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
[2024-09-06 12:54:01] 7: 0x1120fec v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
[2024-09-06 12:54:01] 8: 0x112314a v8::internal::Heap::HandleGCRequest() [node]
[2024-09-06 12:54:01] 9: 0x108e7b7 v8::internal::StackGuard::HandleInterrupts() [node]
[2024-09-06 12:54:01] 10: 0x15310b2 v8::internal::Runtime_StackGuardWithGap(int, unsigned long*, v8::internal::Isolate*) [node]
[2024-09-06 12:54:01] 11: 0x196aef6 [node]
[2024-09-06 12:54:01] Aborted
[2024-09-06 12:54:01] npm notice
[2024-09-06 12:54:01] npm notice New patch version of npm available! 10.8.2 -> 10.8.3
[2024-09-06 12:54:01] npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
[2024-09-06 12:54:01] npm notice To update run: npm install -g npm@10.8.3
[2024-09-06 12:54:01] npm notice
[] was terminated
[2024-09-06 12:54:18]
[2024-09-06 12:54:18] > omni-crm-server@1.0.0 start
[2024-09-06 12:54:18] > nest start
[2024-09-06 12:54:18]
I have added the following App-Level Environment Variable
Key: NODE_OPTIONS Value: --max-old-space-size=4096
Starting the server still failing and here are the full logs
[2024-09-06 13:34:12] ✔ build complete
[2024-09-06 13:34:24] > omni-crm-server@1.0.0 start
[2024-09-06 13:34:24] > nest start
[2024-09-06 13:34:24]
[] was terminated
[2024-09-06 13:35:06]
[2024-09-06 13:35:06] > omni-crm-server@1.0.0 start
[2024-09-06 13:35:06] > nest start
[2024-09-06 13:35:06]
How can i fix that?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Heya,
It looks to me like your NodeJS application requires a lot of RAM for it to run. My suggestion would be upgrading the container for your web component to have more RAM so that you can run your App.
Hi there,
How much RAM does the component that you are using have? The error you’re encountering, “JavaScript heap out of memory,” is related to Node.js running out of memory during execution.
This is a common issue when working with large applications or when deploying apps on environments with limited resources.
What I would suggest here is upgrading the container for your web component to a one with more RAM to make sure that your app has enough resources.
One another note, while running your application locally on your laptop, check if there are any memory leaks or inefficient code in your application that might be consuming more memory than necessary. Tools like Chrome’s Node.js profiling tools can help identify memory leaks:
Let me know how it goes!
- Bobby