Skip to content

Decrease memory footprint when handling large attachments - #356

Open
csu333 wants to merge 1 commit into
asternic:mainfrom
csu333:pr-streaming-perf
Open

Decrease memory footprint when handling large attachments#356
csu333 wants to merge 1 commit into
asternic:mainfrom
csu333:pr-streaming-perf

Conversation

@csu333

@csu333 csu333 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

I’m currently working on a small project where I use WuzAPI on a constrained system (1 GB of RAM). The handling on large attachments such as video just won’t work because of the multiple copies of the objects in memory. To sort that out, I made a few changes:

  • Reusing the same objects when possible
  • Don’t convert to Base 64 before it’s actually needed
  • Streaming the content to only have part of the attachment in memory at any time

I made my best not to break any existing feature. People not activating streaming will observe that the message in form-data will have the userID/instanceName information twice (once at top level and once in the form data since it’s injected by sendEventWithWebHook), but they will otherwise benefit from a decrease of the memory footprint (especially when handling large files).

As Go is not my language of preference, I relied on several AI models to produce and review my code. I would therefore understand any push back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant