question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lower memory consumption: SpringSingleMultipartFileWriter

See original GitHub issue

The write method of SpringSingleMultipartFileWriter.java uses a lot of memory:

@Override
  protected void write (Output output, String key, Object value) throws EncodeException {
    val file = (MultipartFile) value;
    writeFileMetadata(output, key, file.getOriginalFilename(), file.getContentType());

    byte[] bytes;
    try {
      bytes = file.getBytes();
    } catch (IOException ex) {
      throw new EncodeException("Getting multipart file's content bytes error", ex);
    }
    output.write(bytes);
  }

Is it possible to use file.getInputStream() in some kind of way? It will require a lot of refactoring… now large files are loaded inside the memory twice.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:5

github_iconTop GitHub Comments

2reactions
Toparvioncommented, May 12, 2020

Facing the same issue with transferring uploaded files through Feign-equipped applications. It would be much more efficient for memory consumption if Feign could treat uploaded files as byte streams rather than byte arrays.

1reaction
tmoreira2020commented, Feb 6, 2021

Thanks @koziolk for the fast response. I was thinking to do the same approach and have two clients for the short term.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reduce memory usage on your Mac - Setapp
Fix "kernel_task", a high CPU usage bug · Reduce memory usage in Finder · Improve Chrome's Task Manager · Clean up browsers ·...
Read more >
how to reduce spring boot memory usage? - Stack Overflow
My JVM options are (-Xmx64M -Xms64M -XX:MaxPermSize=64M -server), why is it that in the x64 server, memory usage is so big? how to...
Read more >
How to clear RAM on Mac and reduce memory usage - MacPaw
Tip # 1. Remove Login Items to lower Mac memory usage. Login Items are programs that load automatically upon Mac startup. Some of...
Read more >
Optimizing Memory Usage in Python Applications
Find the reasons why your Python applications are using too much memory, analyze them and reduce their memory consumption and footprint using simple...
Read more >
How to Lower Memory (RAM) Usage on Mac - BuhoCleaner
This blog post will tell you how to free up RAM and reduce memory usage in eight easy ways.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found