简体   繁体   English

JPA持续存在大斑点

[英]JPA persist large blob

I'm trying to persist an Entity with a large blob file, and I got an "Out of Memory" error in the JBoss log. 我正在尝试使用大blob文件来保留实体,并且在JBoss日志中出现“内存不足”错误。

I test with several configurations, but always get the same result. 我测试了几种配置,但始终得到相同的结果。 I'm using jBoss 6 and MySQL. 我正在使用jBoss 6和MySQL。

An example of this... Entity: 此示例...实体:

@Entity
@Table(name="ficheros")
public class Fichero implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column(unique=true, nullable=false)
    private int idfichero;

    @Lob()
    @Column(nullable=false)
    private Blob fichero;

    public Fichero() {
    }

    public int getIdfichero() {
        return this.idfichero;
    }

    public void setIdfichero(int idfichero) {
        this.idfichero = idfichero;
    }

    public Blob getFichero() {
        return this.fichero;
    }

    public void setFichero(Blob fichero) {
        this.fichero = fichero;
    }   
}

The class: 班级:

public Integer insertaFichero(Fichero fich) {
    ficheroDAO.create(fich);

    return fich.getIdfichero();
}

Is there another way to do that? 还有另一种方法吗?

The problem with this error is that the operating system cannot allocate more memory for the threadstack so it fails to instantiate a new thread. 该错误的问题是操作系统无法为线程堆栈分配更多的内存,因此它无法实例化新线程。 Probably it's not a JBoss issue. 可能不是JBoss问题。 You have to reduce the amount of memory each thread uses. 您必须减少每个线程使用的内存量。 A fine size for JBoss threads is 128k or 256k. JBoss线程的合适大小为128k或256k。

You can look at this articles from JBoss documentation 您可以从JBoss文档中查看此文章。

https://community.jboss.org/wiki/OutOfMemoryExceptions?_sscc=t . https://community.jboss.org/wiki/OutOfMemoryExceptions?_sscc=t

https://community.jboss.org/wiki/OutOfMemoryExceptionWhenCannotCreateThread . https://community.jboss.org/wiki/OutOfMemoryExceptionWhenCannotCreateThread

See also the stackoverflow question: Safe thread stack size? 另请参阅stackoverflow问题: 安全线程堆栈大小?

To reduce this memory amount, in linux I found the command: 为了减少此内存量,在Linux中我找到了以下命令:

ulimit -s 256

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM