CRITICAL ISSUE: Mark-compact processes not performing effectively close to heap capacity

I encountered an error and I'm seeking a brief explanation to help me understand what needs to be fixed.

This error occurs during the compilation of TypeScript.



<--- Last few GCs --->

[1791:0x5533880]    72626 ms: Scavenge (reduce) 2042.8 (2082.2) -> 2042.1 (2082.5) MB, 10.0 / 0.0 ms  (average mu = 0.287, current mu = 0.243) allocation failure 
[1791:0x5533880]    74247 ms: Mark-sweep (reduce) 2043.0 (2082.5) -> 2037.5 (2082.5) MB, 1617.4 / 0.0 ms  (average mu = 0.225, current mu = 0.159) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb09c10 node::Abort() [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 2: 0xa1c193 node::FatalError(char const*, char const*) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 3: 0xcf8dbe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 4: 0xcf9137 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 5: 0xeb09d5  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 6: 0xeb14b6  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 7: 0xebf9de  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 8: 0xec0420 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
 9: 0xec339e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
10: 0xe848da v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
11: 0x11fd626 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]
12: 0x15f2099  [/opt/hostedtoolcache/node/16.15.0/x64/bin/node]

Node.js : 16.15.0 TypeScript : 4.2.4

Answer №1

Your memory usage has reached approximately 2GB, and the garbage collector is struggling to release any memory. An allocation request requires more memory than is currently available, leading to a situation where a crash becomes the only viable solution.

Potential Solution 1: reduce memory consumption. The method to achieve this will vary depending on the nature of your application:

  • Consider clearing or reducing the size of any caches in use
  • Work with smaller data chunks or handle fewer concurrent requests
  • Explore more memory-efficient ways to represent your data
  • Identify and correct any memory leaks within your code, where objects are being held unnecessarily
  • There may be several other options to consider as well.

Potential Solution 2: increase Node's memory allocation using --max-old-space-size=3000 (or specify a value higher than the current/default limit in megabytes).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Javascript to implement a tooltip feature for dynamically inserted text

I recently incorporated a brief jQuery tooltip plugin into my site. It consists of approximately ten lines of code and works smoothly, as demonstrated in this demo. However, I encountered an issue when attempting to add new text that should also trigger t ...

Displaying live IP CAMERA feed using three.js

I am currently facing a challenge in rendering a video stream from an IP Camera to a three.js texture. I have attempted the following code snippet without success: .... var video = document.createElement('video'); video.crossOrigin="anonymous" ...

The function onReady() fails to trigger the execution of $.getJSON() upon page restoration in the browser

Initially, I want to mention that the code below functions perfectly when I launch a new browser tab and enter my web server's URL. It also works fine when I reload the page (using F5 or Ctrl-R). However, it only partially works if I reopen a closed b ...

ways to deliver a message from server to client's body

Here is the Java server code I am using: private Response createError(int code, String error) { logger.error(error); return Response.status(code).entity("{ \"errorMsg\": \""+error+"\"}").build(); } And this is the client code: ...

Update the table that includes a php script

I have a piece of PHP code embedded within a table tag that displays text from a database. I am looking for a way to automatically refresh this table every minute with updated content from the database, without refreshing the entire page. While I have co ...

Creating jQuery objects with concise code

I'm in the process of integrating caching and minimizing DOM manipulation in my highly intricate JS code. I am keen to ensure efficiency, so I'm wondering which approach is more optimized? 1) var $thebox = $(".textbox[data-title*='"+dt+"&a ...

Why Does React Material-UI Switch Styling Keep Changing Sporadically?

Currently, I am trying to integrate a switch component from MUI into my code. Strangely enough, upon the initial page load, the switch appears exactly as it should - identical to the one displayed on the MUI site. However, upon reloading the page, it under ...

Accept only requests from my Chrome extension

I have successfully set up a NodeJS server with Express on DigitalOcean. My Chrome extension is able to make GET calls to the server without any issues. However, I am looking to enhance the security of the middleware below: // Add headers app.use(function ...

The x-axis values in Amchart are transitioning rather than shifting

I'm facing an issue with my x-axis values as I'm using real-time amcharts. The x-axis values change every 3 seconds, but instead of smoothly moving, they abruptly change to the next value. I would like it to slide smoothly like this example: htt ...

What is the best way to terminate a "for await ...of" loop if it fails to finish within a specified timeframe?

Is it possible to stop an asynchronous loop if it doesn't finish within a set time frame? I'm working with the following code: (async()=>{ for await(let t of asynDataStreamOrGenerator){ //some data processing } //some other code I n ...

What is the best approach for adding variable rows to a Postgres junction table: should you concatenate a query string, utilize multiple queries, or explore alternative methods

Below is the code snippet for handling a variable-length list of tags and inserting data into the database: // JSON object from req.body { "title": "title", "reference": "1213", "noteType": &q ...

Executing javascript functions from various HTML tags

The code snippet below is what I currently have: <script src="jquery-1.10.2.min.js"></script> <script> $('#year li').click(function() { var text = $(this).text(); //alert('text is ' + text); $.post("B.php" ...

Issues are arising with Bootstrap's functionality within the Vite React app

I am new to working with react and vite. I am currently developing a vite react application that requires the use of bootstrap. I followed the instructions provided on the official Bootstrap website here. However, not all Bootstrap functionalities are work ...

Deleting content in a text area when specific text is entered

Is there a way to clear the textarea value if I type in <br>? The code I have right now is shown below. I understand that this may seem like an odd request, but I am experimenting with a typing effect. function eraseText() { document.getElemen ...

Converting values into keys and vice versa in JavaScript: A comprehensive guide

I have an array of Objects where I want to convert the first value into a key and the second value into a value. Please review the question below along with my desired output: [ { "name": "Unknown", "value": "R ...

Transform the JavaScript onclick function into jQuery

I have been working on incorporating my javascript function into jQuery. The functionality I am aiming for is that when you click on a text (legend_tag), it should get added to the textarea (cartlist). <textarea id="cartlist"></textarea& ...

Using Regular Expressions in Javascript

I have gone through numerous posts with this title, but so far, none of them have addressed my specific query... My requirement is to utilize regex in the following format: "/^ user provided input $/i". The user can include the special regex character * e ...

What is the procedure for attaching console.log to "l" in vue.js?

The code in main.js includes the following: window.l = function () { } try { window.l = console.log.bind(console) } catch (e) { } It functions properly in non-Vue applications. However, when trying to use it in a Vue action/method like this: l("test") ...

Ways to retrieve form information from a POST request

I received a POST request from my payment gateway with the following form data: Upon trying to fetch the data using the code snippet below, I encountered errors and gibberish content: this.http .post<any>('https://xyz.app/test', { ti ...

JavaScript sticky navigation bar - error displayed in console

Hey there, I'm having an issue with my Sticky-menu. I've been trying to troubleshoot it but keep getting these console error messages: 1. Cannot read property 'offsetTop' of null at HTMLDocument. 2. Cannot read property 'class ...