How can I change the memory limit in n8n?

Hello! I need help with change the limit size of memory of n8n in code? What folder I need acess to find the file to change te memory limit?
In the first picture I’m showing the file system of my version that it is in second picture.

Can someone help me?

Hey @Viniciusmq107,

It doesn’t really work that way, we run on nodejs but the memory limit may vary depending on how you deploy n8n.

You can find some of the node options you can set here: Command-line API | Node.js v19.0.0 Documentation

I think the option you would need is max old space size.

I saw this function of max old space in other answer in n8n community, bus I do not know exactly set this option in files of n8n. Do you know?

Hey @Viniciusmq107,

It isn’t something you would set in one of the n8n files it looks like it is an environment option you would need to set before launching n8n a bit like the other options that need to be set like WEBHOOK_URL

Hey!

We had the same problem with a workflow needing more memory, if you use Docker u can set the

NODE_OPTIONS=--max_old_space_size=8000

(8000 MB)
environment variable in your Docker-Compose

4 Likes

Hello everyone, I am jumping in this thread.
I am occurring in the same error with a SFTP download request.
Can you explain me how to increase the memory limit?

Hey @Gabriele_Bracciali,

What error are you seeing with the download?

hey @Jon , thanks for reply
If i run the same node in cloud version:
There might not be enough memory to finish execution. Tips for avoiding this here n8n

If i run in local npm:
ERROR: Cannot create a string longer than 0x1fffffe8 characters

Hey @Gabriele_Bracciali,

Perfect, So the string longer than message is one I have seen before but I would expect it to be an issue if you were doing something with a file that is over 512MB this is a NodeJS limit but not really related to memory.

To fix this you will need to use the filesystem option for the data and the rest will depend on which node you are using as some support the data streaming option and others don’t yet.

hey @Jon , could you make an example please?

Hey @Gabriele_Bracciali,

Example of what? Can you tell me which node you are using and what config options you have set I can then tell you if it will work or not.

I take it you are trying to work with a file over 512mb as well right?

I am using FTP node, and yes really over 512mb

Perfect, assuming you are on the latest release of n8n you should be good to go and it would be a case of making sure you have N8N_AVAILABLE_BINARY_DATA_MODES set to filesystem which should be the default but if you are in queue mode it might be different.

I am using npm local version 0.202.1

And this is the point I don’t get, how to edit this:

Hey @Gabriele_Bracciali,

You will need to upgrade n8n, the streaming support for the FTP node was introduced in 0.214.0 (Release notes - n8n Documentation).

That option would be set like any of the other environment options. How you set it would depend on how you have n8n running but as you are already running n8n if you know where you set the webhook_url option it would be the same place.

Setting env options: Configuration methods - n8n Documentation

Same error.
I’ve also tried to lunch localhost with the command to increase memory:

NODE_OPTIONS="--max-old-space-size=4096" npx n8n

but doesn’t work same

Hey @Gabriele_Bracciali,

From what I understand the error doesn’t have anything to do with memory as such and it is more around how the file is being handled (in memory vs on local disk) with a data stream.

Assuming you are now on the latest release can you make sure that N8N_AVAILABLE_BINARY_DATA_MODES is set to filesystem, I have done a test locally here and I have been able to download a 3GB file.

I’ve added the line to the config file, but I receive the same error.

"N8N_AVAILABLE_BINARY_DATA_MODES":"filesystem"

Local Version: 0.214.0

Hey @Gabriele_Braccialim,

Can you try the latest release? I wouldn’t recommend 214 because of the recent issues. Is this actually failing on the download or when using the data?

During the download in the FTP node