Out of memory while running layout collector

Dear Sir or Madam,


I have code which produces a report. While producing a report it calculates the number of rows in a table and if it exceeds some precalculated maximum it tries to split it. In order to do it the code adds the table to the document recalculates layout and looks for the first row to be on other page than the last row. The code is following:
LayoutCollector layoutCollector = new LayoutCollector(mOutputDocument);
NodeCollection awRows = contentWrapCell.GetChildNodes(NodeType.Row, true);
string endSplitRowId = null;
string startNewSplitRowId = null;
for (int i = 1; i < awRows.Count; i++)
{
if (layoutCollector.GetEndPageIndex(awRows[i]) != layoutCollector.GetEndPageIndex(awRows[0]))

I have two issues though.
1. Last time while producing a 250+ pages report layoutCollector.GetEndPageIndex threw Out of memory exception (I saved the document before the exception so probably you’ll be able to reproduce it on your side). I have i7 16 Gb laptop so I don’t think the problem is with my hardware.
2. I am aware that LayoutCollector runs slow as it performs a lot of math calculations. So when I have a number of long tables my report generation time could be 20-30 minutes (vs 2-3-4 minutes without splitting tables). I wonder if there is a way to somehow cache the layout collector latest calculation and resume it from the last node added to the document tree.
Regards,
Alex

Hi Alex,


Thanks for your inquiry. I would first suggest you please upgrade to the latest version of Aspose.Words and see how it goes on your side. You can download it from the following link. I hope, this helps.
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

1. It would be great if you please create a standalone runnable simple application (for example a Console Application project) that helps me reproduce this exception on my end and attach it here for testing.

2. I am in communication with our development team and will get back to you as soon as I have information about partially caching and partially calculating the layout information.

Best regards,

Hi Alex,


Alex:
2. I am aware that LayoutCollector runs slow as it performs a lot of math calculations. So when I have a number of long tables my report generation time could be 20-30 minutes (vs 2-3-4 minutes without splitting tables). I wonder if there is a way to somehow cache the layout collector latest calculation and resume it from the last node added to the document tree.
The layout collector class captures information when layout is built. It records map of document nodes to objects from the layout model. Whenever layout is re-built, the existing layout model is discarded – that is all existing layout objects are released and no longer valid. This means that all captured information is no longer applicable and cannot be re-used in any way. For the same reason layout collector must also be discarded.

Reusing existing layout collector could only be possible if corresponding layout model is not discarded but also re-used. Unfortunately, this cannot happen in Aspose.Words as there is no such mechanism which allows synchronizing arbitrary changes in the document model with existing layout model. This is only possible during field update, but not when document model is manually changed.

It is unlikely that this sort of functionality would ever be implemented in AsposeWords. It’s only expected from word processor applications like Microsoft Word itself which renders document in response to changes made by the user in real time.

Best regards,