response.setContentType("image/jpeg");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
        AbstractSeal.setMm(pxPerInch / 25.4);
int height = (int) (frameHeight * AbstractSeal.mm + left * 2);
int width = (int) (frameWidth * AbstractSeal.mm + top * 2);
Seal seal = generateSeal(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.fillRect(0, 0, image.getWidth(), image.getHeight());
if(carvingType==1){ DefaultSealFrame frame = new DefaultSealFrame(left, top, frameWidth * AbstractSeal.mm, frameHeight
* AbstractSeal.mm, frameLineWidth * AbstractSeal.mm, frameType);
SealChipNest chipNest=new SealChipNest(14*AbstractSeal.mm, frame);
chipNest.draw(g2);
}
else if (isPrintable()) {
seal.setPrintable(true);
seal.draw(g2);
// 镜像
final AffineTransform hFlip = new AffineTransform(-1.0, 0, 0, 1.0, width, 0);
g2.drawImage(image, hFlip, null);
} else {
seal.draw(g2);
}
// AbstractSeal abstractSeal=(AbstractSeal) seal;
// abstractSeal.saveDraw();
g2.dispose();
ImageIO.write(image, "jpeg", response.getOutputStream());
                response.getOutputStream().flush();

一次性显示很多图片的时候 在BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);这行报内存溢出 请大家帮我看看.....

解决方案 »

  1.   

    Image本来就是非常消耗内存的东西如果不能控制一次性处理图片的数量,就只能设法增加JVM内存: -Xmx1024m
      

  2.   

    我现在增加了JVM内存 大概用户是30个人 一个页面做多显示六个图片 这样应该没问题了吧
      

  3.   

    那叫泄露,Image确实很耗内存。没关系Java嘛,啥不费内存呢?
      

  4.   

    现在想除了增加JVM内存 程序中是否可以完善 呵呵
      

  5.   

    不知道你图片多大,其实自己可以粗略估算下:假设图片大小为 1024×768,采用真彩色,也就是4位色彩体系。那么每张图片仅存储空间开销为 3MB。30用户,每个用户6张图片,即180张。3MB×180=540MB也就是仅仅图片存储空间开销,就不低于540MB。
      

  6.   

    三十个用户 同时刷新页面 显示图片 这样会不会 报内存溢出 现在担心的是这个问题 虽然 JVM内存设置过了
      

  7.   

    应该出现这样极端情况的概率偏低,毕竟只有输出的时候才会需要占住内存,输出完毕后就可以回收了。不过你也可以选择将中间件进行集群,这样就会更宽松些,另外也预防单点故障。另外,32bit环境下,内存最多可以配置到 1.5GB~1.75GB左右。