1 Reply Latest reply on Dec 8, 2006 5:11 AM by aidan davis

    Blob reading causing memory leak?

    aidan davis Newbie

      I have three entity beans; one Audit contains many AuditImage, one AuditImage contains one AuditLargeImage .

      Audit to AuditImage is eagerly loaded, AuditImage to AuditLargeImage is lazily loaded.

      I can sucessfully upload images to the database (MySQL) but when I load (manager.find) the Audit, the servers memory usage jumps to over 1GB! Despite total image size being only 5mb

      @Entity(name = "Audit")
      public class Audit {
      
      private Set<AuditImage> image;
      
       @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
       public Set<AuditImage> getImages() {
       if (image == null)
       image = new HashSet<AuditImage>();
       return image;
       }
      
       public void setImages(Set<AuditImage> image) {
       this.image = image;
       }
      }
      
      }
      


      @Entity
      @Table(name = "auditimage")
      public class AuditImage {
      
       private int id;
      
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       private String imageName;
      
       private byte[] imageThumb;
      
      private AuditLargeImage imageLarge;
      
       @Lob
       @Column(columnDefinition = "BLOB")
       public byte[] getImageThumb() {
       return imageThumb;
       }
      
       public void setImageThumb(byte[] imageThumb) {
       this.imageThumb = imageThumb;
       }
      
       public String getImageName() {
       return imageName;
       }
      
       public void setImageName(String imageName) {
       this.imageName = imageName;
       }
      
      @OneToOne(cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
       public AuditLargeImage getImageLarge() {
       return imageLarge;
       }
      
       public void setImageLarge(AuditLargeImage imageLarge) {
       this.imageLarge = imageLarge;
       }
      }
      


      @Entity
      public class AuditLargeImage {
       private int id;
      
       @Id
       @GeneratedValue(strategy = GenerationType.AUTO)
       public int getId() {
       return id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      
       private byte[] imageFull;
      
       @Lob
       @Column(columnDefinition = "MEDIUMBLOB")
       public byte[] getImageFull() {
       return imageFull;
       }
      
       public void setImageFull(byte[] imageFull) {
       this.imageFull = imageFull;
       }
      
      }
      
      


      Am currently using JBOSS 4.05 GA, Hibernate 3.2.1 with the latest mysql jdbc connector (5.0.4).

      Even if I remove all references to AuditLargeImage (as in disregard it from the test) I still have the same problem...

      Your comments appreciated. Thanks