Free Support Forum - aspose.com

Handling SystemOutOfMemory exception

We are evaluating your Words product and are running into a problem when trying to merge data into a large template. In this case, the template is about 3MB. It takes fewer than 30 merged records to cause a SystemOutOfMemory exception. The server has several gigs of memory so we're wondering why it would error out with a document under 100MB. First, is there a way to handle larger documents and if not, is there a way to make it fail more gracefully? The merge is wrapped in a try block but the SystemOutOfMemory exception does not seem to be raised to the page.

Well, if you attach this document here we will try to reproduce the problem and maybe come up with some code optimization. But generally, the documents having 30 megabytes and more are considered extremely large and should better be avoided. I think you will most probably have difficulties with openning and working with them in MS Word even if they will be created by Aspose.Words correctly.

In your case I suggest that another approach should be taken. You should open/mailmerge/save the document in the loop for each record. In that way you will have 30+ merged documents as the output instead of having one extremely big document. Please let me know if that fits you.

Best regards,