Unable to render - Low Memory

Posted by: kpenigar-fp on 8 September 2017, 2:53 pm EST

  • Posted 8 September 2017, 2:53 pm EST

    Hi,

     I know this particular issue has been covered, but I'm experiencing something I think may be a little different.  After the data is presented, I have a routine that does some summary calculations and plugs the results in the last row of the sheet.  I also try to format the text of the cells in that row.  The routine works fine as long as I don't try to format the text.  I have posted the code below:

    private void AddStatistics()
          {
             FarPoint.Win.Spread.CellType.PercentCellType percentCellType = new FarPoint.Win.Spread.CellType.PercentCellType();
             percentCellType.DecimalPlaces = 2;
            
             try
             {
                if (spreadSheet.RowCount > 4)
                {
                   spreadSheet.Rows.Add(spreadSheet.RowCount, 1);
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 7, spreadSheet.RowCount - 1, 10].CellType = percentCellType;

                   spreadSheet.Cells[spreadSheet.RowCount - 1, 0].Text = (spreadSheet.RowCount - 1).ToString();
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 7].Formula = string.Format("1-(SUBTOTAL(9,R1C:R{0}C)/SUBTOTAL(3,R1C:R{0}C))", spreadSheet.RowCount - 1);
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 8].Formula = string.Format("1-(SUBTOTAL(9,R1C:R{0}C)/SUBTOTAL(3,R1C:R{0}C))", spreadSheet.RowCount - 1);
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 9].Formula = string.Format("1-(SUBTOTAL(9,R1C:R{0}C)/SUBTOTAL(3,R1C:R{0}C))", spreadSheet.RowCount - 1);
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 10].Formula = string.Format("1-(SUBTOTAL(9,R1C:R{0}C)/SUBTOTAL(3,R1C:R{0}C))", spreadSheet.RowCount - 1);
                   spreadSheet.Cells[spreadSheet.RowCount - 1, 12].Text = "Percent Zero Count";


                   using(Font f = new Font("Century Gothic",9, FontStyle.Bold))
                   {
                      spreadSheet.Cells[spreadSheet.RowCount - 1,0, spreadSheet.RowCount - 1, 12].Font  = f;
                   }
                }
             }
             finally {percentCellType.Dispose(); }
          }

    I appreciate any help I can get.

    Thanks

  • Replied 8 September 2017, 2:53 pm EST

    Hi,

    That message shows when there is an exception that happens during the painting, usually in IRenderer.PaintCell.

    You should not dispose the cell type before you're finished with it, and you should not dispose the font either (using will automatically dispose it when it goes out of scope).  When a managed property on a disposed object is accessed, it causes an ObjectDisposedException.

  • Replied 8 September 2017, 2:53 pm EST

    Thanks, that did the trick.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels