[jboss-user] [EJB 3.0] - Blob reading causing memory leak?
aidan_b5
do-not-reply at jboss.com
Thu Dec 7 11:23:29 EST 2006
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991995#3991995
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991995
More information about the jboss-user
mailing list