I use sttp lib with akka backend to load a file from server. Either of the following approaches results in significant memory footprint to load 1Gb file:
import com.softwaremill.sttp._
val file: File = new File(...)
sttp.response(asStream[Source[ByteString, Any]])
.mapResponse { src =>
src.runWith(FileIO.toPath(file.toPath, options, 0))
}
sttp.response(asFile(file, false))
VisualVM plots of sequential loads for 1Gb file.
Is there any chance to write data in chunks and evict chunks from memory right after the write?