Spring会将内容保存在内存中还是存储在磁盘中? [英] Will Spring hold contents in memory or stores in the disk?

查看:564
本文介绍了Spring会将内容保存在内存中还是存储在磁盘中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个文件说从浏览器上传100 MB大小时,Spring会将整个数据保存在内存中或临时存储在磁盘中。通过Spring doc之后,我知道如何设置临时目录,但我想知道如果我不提及会发生什么。

When a file say 100 MB size is uploaded from browser will Spring hold whole data in memory or stores in the disk temporarily. After going through Spring doc I know how to set a temp dir but I want to know what will happen if I don't mention that.

我有以下声明:

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>

Bean:

public class FileHolder {

    private MultipartFile file;

    public void setFile(MultipartFile file) {
        this.file = file;
    }

    public MultipartFile getFile() {
        return file;
    }
}

上述bean中的file对象是否成立那个100 MB的数据?

Will the "file" object in the above bean hold that 100 MB data ?

推荐答案

javadoc 显示默认最大值-memory大小为10240字节。由此我假设任何小于10kB的上传都保存在内存中,任何更大的内容都将存储在磁盘上。如果你没有指定磁盘位置,它可能会使用默认值(我猜它会使用系统默认的tmp目录)。

A bit more digging in the javadoc shows that the default maximum in-memory size is 10240 bytes. From that I'd assume that any upload less than 10kB is held in memory, anything larger will be stored on disk. If you don't specify the disk location, it'll likely use a default (I'd guess it'll use the system default tmp directory).

这篇关于Spring会将内容保存在内存中还是存储在磁盘中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆