Memory usage issues after get buffer

I have a code node, and this node acquires the buffer of the previous node. And pass this buffer to the next node. However, as soon as I connected this node in the workflow, my chrome memory soared directly to 4,000,000K

image

Information on your n8n setup

  • **n8n version: latest
  • **Database (default: SQLite):SQLite
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • **Operating system: windows10
1 Like

hello @Menghan_Tang

What is your use case?
Why are you trying to work with binary data in the code node?
How big is the input file?

Hey,

what’s happening is that getBinaryDataBuffer() loads the whole file into memory, and if you console.log it directly this is probably the issue.

to fix you can probably do something like this

let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, "data");
console.log("Buffer size:", binaryDataBufferItem.length); // way safer
return items;

Also, make sure you’re returning items, not the buffer itself.

Hope that helps! Let me know :+1:

It is a binary of an image. I need to use the request node to send this binary data. The format he needs must be a byte array。I have now found a suitable open-source node to do this. Thank you

1 Like

It’s indeed caused by console.log. Thank you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.