Hello, Everybody,
I use Aspose.Words for Java for converting large amounts of .doc-files into .docx-format.
For this purpose I ‘remote control’ a Java VM. Anything else happens outside the VM using Ruby.
The VM is not used for anything except
- opening the document
- removing macros
- saving the document.
I can reproduce “OutOfMemoryError: Java heap space” after ca. 650 conversions when the VM can use 1GB of heap.
I can reproduce “OutOfMemoryError: Java heap space” after ca. 1300 conversions when the VM can use 2GB of heap.
(This happens quite independently of the version of Aspose.Words. I have the same problem with version 3.0, 3.3 and 10.0)
Kind regards,
Martin
Hi Martin,
Thanks for your request. Which version of Aspose.Words do you use? Have you tried using the latest version of Aspose.Words for Java? You can get the latest version from here:
https://releases.aspose.com/words/java
Also, could you please attach one or few documents that you need to convert to DOCX? I will try to emulate the problem on my side and provide you more information.
Best regards,
Hello, Alexey,
thanks for your quick reply.
I will test using v10.0.1 later today but having a look at the changelog I am not very optimistic about the outcome since the changes seem to address mostly documentation problems and 10.0.0 behaves badly.
I will attach some word data as soon as I have cleared this with my customers.
Kind regards,
Martin
Hello, Alexey,
as expected, Aspose.Words v10.0.1 shows the same behaviour as 10.0.0.
Best regards, Martin
Hi Martin,
Thank you for additional information. But, unfortunately, I cannot reproduce the problem on my side. For testing purposes, I tried converting 200 DOC files to DOCX. Here is code I used for testing:
File dir = new File("folder with test DOC files");
File[] files = dir.listFiles();
int i = 0;
for (File file: files)
{
Document doc = new Document(file.getAbsolutePath());
doc.removeMacros();
doc.save("C:\\Temp\\out_" + i++ + ".docx");
}
I also tried to decrease JVM heap size, but still cannot reproduce the problem. For testing is specified heap size = 32 MB.
Maybe the problem occurs upon converting some specific document on your side. Have you tried to convert the same document many times? Does the problem occur in this case?
Also, please show me your code.
Best regards,
Hello, Alexey,
it takes very complex documents or very many iterations to reproduce this problem.
Luckily, it is enough to convert the same file over and over again.
With the attached file and a heap size of 32MB the test crashes after about 1400 iterations.
My code is very similar to yours (3 steps, open file, remove macros, save file, all put into a loop) but hard to reproduce in java exactly since I am using ruby to remote-control the java-VM.
Hope this helps to reproduce the problem.
Best regards,
Martin
Hi Martin,
Thank you for additional information. But unfortunately, I still cannot reproduce the problem. I used the following code with 32MB heap and no exceptions occurs.
for (int i = 0; i <1000000; i++)
{
Document doc = new Document("C:\\Temp\\17.doc");
doc.removeMacros();
doc.save("C:\\temp\\out.docx");
}
Maybe in your code something does not release memory. Improperly closed stream or something like this.
Best regards,
Hello, Alexey,
pity you could not reproduce the problem.
Could it make a difference which version of Java I am using?
I use Aspose.Words.jdk15.jar with java 1.5.0.
Other than that I see no difference between the code I inject into the VM and the block of your loop.
Best regards,
Martin
Hi Martin,
Thank you for additional information. I also used Aspose.Words.jdk15.jar for testing. But I used Java 1.6 on my side.
Also today, I tried with more iterations and still no problems. Loop worked about 3 hours without any problems.
Best regards,
Hello, Alexey,
I finally managed to reproduce the flawless working of the Java implementation.
The problem was with the garbage collector of the software I use to inject the Java code.
Sorry for inconveniencing you.
Best regards,
Martin
Hi Martin,
It is perfect that you managed to resolve the problem. Please feel free to ask in case of any issues, we are always glad to help you.
Best regards,