> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory.md).

# NodeJS - JavaScript heap out of memory

### Problem <a href="#problem" id="problem"></a>

When running the SeaLights NodeJS agent, the error "`JavaScript heap out of memory`" is encountered.

### Solution <a href="#solution" id="solution"></a>

By default node is limited in the amount of memory it is allocated, and sometimes the SeaLights node agent requires more memory that what was allocated.\
More memory can be allocated by using the `max-old-space-size` flag.

The flag can be passed either by **using the NODE\_OPTION environment variable**, for example:

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" lineNumbers="true" %}

```sh
export NODE_OPTIONS=--max-old-space-size=4096
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```powershell
set NODE_OPTIONS=--max-old-space-size=4096
```

{% endcode %}
{% endtab %}
{% endtabs %}

Alternatively, it can be **passed directly to node process** running the SeaLights agent, for example:

{% code overflow="wrap" lineNumbers="true" %}

```
node --max-old-space-size=4096 ./node_modules/.bin/slnodejs scan ...
```

{% endcode %}

{% hint style="info" %}
To show the current max heap size being used by Node.js *at runtime* (after accounting for `NODE_OPTIONS` or any CLI overrides), you can execute:

```
node -p "v8.getHeapStatistics().heap_size_limit / 1024 / 1024 + ' MB'"
```

{% endhint %}

### Related articles <a href="#related-articles" id="related-articles"></a>

* [Running Tests](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/go-agent/go-agent-v1/running-tests.md) (Go)
* [Setting up a windows service](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-a-windows-service.md) (.Net Core)
* [Setting up IIS Listener](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-iis-listener.md) (.Net Core)
* [Cloud Foundry Integration](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/capturing-coverage-from-runtime-application/cloud-foundry-integration.md) (Python)
* [Pivotal Cloud Foundry (PCF) Support](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/pivotal-cloud-foundry-pcf-support.md) (Java)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/node-javascript/nodejs-javascript-heap-out-of-memory.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
