Microsoft Developer Network > Forenhomepage > XML Paper Specification (XPS) > Increasing memory leak with batch writing
Stellen Sie eine FrageStellen Sie eine Frage
 

Allgemeine DiskussionIncreasing memory leak with batch writing

  • Mittwoch, 11. März 2009 18:15Hmeidi TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    Hello All,

    I have a problem of increasing memory allocation when I use VisualsToXpsDocument to batch write a large number of pages (1000 pages) with print ticket to Xps document.

    Here is the code that I used:

     

          // use batch writer with ticket

       _ xpsBatchWriter = static_cast<VisualsToXpsDocument __gc*>  (_xpsDocumentWriter ->CreateVisualsCollator());

        _xpsBatchWriter ->BeginBatchWrite();     

    for (int i = 0 ; i < 1000 ; i++)

    {

          ticket = __gc new PrintTicket();

          containerVisual = __gc new ContainerVisual();

          pageMediaSize = __gc new PageMediaSize(sz.Width, sz.Height);

          ticket ->PageMediaSize = pageMediaSize;

          ticket ->PageOrientation =

          (sz.Width > sz.Height)? PageOrientation::Landscape : PageOrientation::Portrait;

          containerVisual ->Children->Add(fixedPage);

          _xpsBatchWriter ->Write(containerVisual , ticket );

    }

            _xpsBatchWriter ->EndBatchWrite();

     

     

    The allocated memory will continue to increase with each page written.

    I don't know if there is some resources should be released or is it a bug at DotNet framework.


    I'll be so thankful if anyone could help me.

     

     

    Regards,

    Hmeidi.


    • Typ geändertHmeidi Donnerstag, 12. März 2009 06:14
    •  

Alle Antworten