Creating table with slides 7.3 version results in OutOfMemory Error

Example from above link, Creating a table from scratch is resulting in OutOfMemory error

Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at java.nio.CharBuffer.wrap(CharBuffer.java:350)
at java.nio.CharBuffer.wrap(CharBuffer.java:373)
at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:138)
at java.lang.StringCoding.decode(StringCoding.java:173)
at java.lang.String.(String.java:444)
at java.util.jar.Manifest.parseName(Manifest.java:252)
at java.util.jar.Manifest.read(Manifest.java:206)
at java.util.jar.Manifest.(Manifest.java:52)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:160)
at java.util.jar.JarFile.getManifest(JarFile.java:146)
at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:693)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:221)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at com.aspose.slides.ado.(Unknown Source)
at com.aspose.slides.bwu.int(Unknown Source)
at com.aspose.slides.bwu.super(Unknown Source)
at com.aspose.slides.bvk.do(Unknown Source)
at com.aspose.slides.bvk.do(Unknown Source)
at com.aspose.slides.bvk.do(Unknown Source)
at com.aspose.slides.bvk.do(Unknown Source)
at com.aspose.slides.bvk.(Unknown Source)
at com.aspose.slides.TextFrameEx.do(Unknown Source)
at com.aspose.slides.TableEx.do(Unknown Source)
at com.aspose.slides.TableEx.do(Unknown Source)
at com.aspose.slides.ShapeEx.const(Unknown Source)

I am using Aspose latest release version 7.3.

Hi Harry,


I have observed the stack trace shared and it seems that you are running low on java heap size. Please increase the java heap size and share with us if there is still an issue. Please share the complete environment, JDK and heap size details in case there is an issue.

Many Thanks,

My Question is - Is memory requirement so huge from Aspose Slides version 2.5 to version 7.3 that it results in Such error.

I am trying to refactor my code which previously used Aspose Slides 2.5 in order to generate a PPTX document. Does every collection used in version 2.5 needs areview for such errors ?

My eclipse.ini configuration

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.1.R36x_v20100810
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m

Also, the code mentioned in this thread generates a very basic table, how this library is going to behave while generating an extremely data extensive table.

Hi Harry,


I have observed the information shared by you. I like to share that legacy versions of Aspose.Slides 2.x.x are entirely different from current Aspose.Slides for Java versions available to date. Aspose.Slides for Java 7.x.x has been developed by autoporting features from latest available Aspose.Slides for .NET and much more enriched in terms of features as compared to predecessor versions of Aspose.Slides for Java 2.x.x series. With more features there are more classes in API that needs to be loaded from Document Object Model (DOM) of Aspose.Slides for Java to memory. This is certainly more than what was required in Aspose.Slides for Java 2.x.x. I have shared the snapshot of my testing with the same sample code pointed by you. You can see from task manager that I touched 35 MB at max for my implementation. I also like to share that we are also working on further improving the performance and memory consumption requirements of Aspose.Slides for Java as well.

Please share, if I may help you further in this regard.

Many Thanks,

Does that mean I need to reimplement my entire document generation code in order to migrate to the latest Aspose Slides library.

Can you please objectively let me understand with above memory configuration, why this simple piece of code is not executing and what are system requirements in order to execute this code.

This would help me much gaining traction over other issues that i will be facing in order to migrate and refactor my existing document generation process supported by Aspose Slides.

//Instantiate PresentationEx class that represents PPTX file

PresentationEx pres = new PresentationEx();

//Access first slide

SlideEx sld = pres.getSlides().get_Item(0);

//Define columns with widths and rows with heights

double[] dblCols = { 50,50,50 };

double[] dblRows = { 50,30,30,30,30 };

//Add table shape to slide

int idx = sld.getShapes().addTable(100, 50, dblCols, dblRows);

TableEx tbl = (TableEx)sld.getShapes().get_Item(idx);

RowEx row=null;

CellEx cell=null;

//Set border format for each cell

for ( int i=0;i< tbl.getRows().getCount();i++ )

{

row=tbl.getRows().get_Item(i);

for (int j=0;j< row.size();j++)

{

cell=row.get_Item(j);

cell.getBorderTop().getFillFormat().setFillType(FillTypeEx.Solid);

cell.getBorderTop().getFillFormat().getSolidFillColor().setColor( Color.red);

cell.getBorderTop().setWidth(5);

cell.getBorderBottom().getFillFormat().setFillType(FillTypeEx.Solid);

cell.getBorderBottom().getFillFormat().getSolidFillColor().setColor( Color.red);

cell.getBorderBottom().setWidth(5);

cell.getBorderLeft().getFillFormat().setFillType(FillTypeEx.Solid);

cell.getBorderLeft().getFillFormat().getSolidFillColor().setColor(Color.red);

cell.getBorderLeft().setWidth(5);

cell.getBorderRight().getFillFormat().setFillType(FillTypeEx.Solid);

cell.getBorderRight().getFillFormat().getSolidFillColor().setColor(Color.red);

cell.getBorderRight().setWidth(5);

}

}

//Merge cells 1 & 2 of row 1

tbl.mergeCells(tbl.get_Item(0, 0), tbl.get_Item(1, 0), false);

//Add text to the merged cell

tbl.get_Item(0, 0).getTextFrame().setText("Merged Cells");

//Write PPTX to Disk

pres.write("c:/test/table7.pptx");

Hi Harry,

If you please observe the snapshot shared by me, you will observe that my memory consumption did not go beyond 40 MB. My max heap size set is 512m on my machine but it never touched that. I am using Windows 7 x64 with JDk 1.6_35 on my end. The above code worked fine in my environment. In my environment it worked fine. Can you please specify the Operting system details along with JDK used on your end. I also like to add that if you are using JDK 1.5 or less then you need to use aspose.slides-7.3.0-jdk14.jar on your end. If you are using JDK 1.6 or above then you need to use aspose.slides-7.3.0.jar on your end. Please share your findings and requested information with us.

Secondly, in order to use the latest Aspose.Slides for Java 3.0.0 and onward versions, you need to port the legacy Aspose.Slides for Java 2.x.x code to newer versions. Please visit this documentation link for your convenience.

Many Thanks ,

I am using Jdk 1.6_12, aspose library aspose.slides-7.3.0-jdk14.jar and having WindowsXP 32 bit.

And the error occurs on the line where I am trying to write the Object on file system.

//Write PPTX to Disk

pres.write("c:/test/table.pptx");

Hi Harry,


As I have shared with you in my previous post that with JDK 1.6 and above you need to use aspose.slides-7.3.0.jar. aspose.slides-7.3.0-jdk14.jar is for JDK 1.4 and JDK 1.5 only. Please try using the specified jar file on your end.

Many Thanks,

Hi Mudassir,

I have changed the library to aspose.slides.7.3.0.jar, The error I am getting now has changed to

Exception in thread “main” java.lang.VerifyError: (class: com/aspose/slides/SlideEx, method: do signature: (Lcom/aspose/slides/pa2137a2a/pbdb106a0/pa5e0ff62/am;)V) Incompatible argument to function
at com.aspose.slides.PresentationEx.do(Unknown Source)
at com.aspose.slides.PresentationEx.(Unknown Source)
at com.aspose.slides.PresentationEx.(Unknown Source)
at TestSlides.main(TestSlides.java:20)

Can you please help me identify potential reason.


Thanks

Hi Harry,


I have observed the stack trace shared by you. It seems like a bug while using Aspose.Slides for Java 7.3.0 with older version of Java as one I am using. I have not been able to reproduce the issue on my end with JDK 1.6_35. I have created an issue with ID SLIDESJAVA-33876 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be addressed and resolved by our development team.

We are sorry for your inconvenience,

Hi Mudassir,

I have tried to run this program with jdk 1.7 as well but the issue persists.
Kindly let me know if jdk version is the only issue?


Thanks

Hi Harry,



Thank you very much for the information. I have updated the issue status with information shared. We will share the feedback with you as soon as the issue will be resolved.

Many Thanks,

The issues you have found earlier (filed as SLIDESJAVA-33876) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.