我目前正在开发apache spark,我正在尝试从web应用程序中运行java代码。当我尝试将代码作为java应用程序运行时,它工作得很好。但是当我尝试将其部署为web应用程序时,当程序到达保存模型的阶段时,即model.save(sparkcontext,modelpath),我收到一个permgen java.lang.OutOfMemory exception。但是,当我尝试将模型编写为对象文件时:
File modelFile = new File(modelPath);
if(!modelFile.exists()){
modelFile.createNewFile();
}
FileOutputStream fout = new FileOutputStream(modelFile);
ObjectOutputStream oout = new ObjectOutputStream(fout);
oout.writeObject(model);
oout.close();它工作得很好。model.save()是如何在apache spark中实现的?
有没有其他保存模型的方法?
提前感谢
发布于 2018-04-03 01:45:23
这是一个纯粹的永久内存,issue.You可以尝试使用以下配置来解决您的问题。
如果您使用的是Oracle提供的JVM,那么可以使用参数-XX:MaxPermSize=256M (or some other amount of space)来增加permgen内存。如果您正在使用任何其他JVM,您可以阅读文档并尝试增加permgen内存。
https://stackoverflow.com/questions/34607959
复制相似问题