System gets slower when animating an annotation.


I am doing an animation, and every 2 seconds I call the following code

mMarkup= new Annot.Ink(CurrentAnno);

However, it appears to be not releasing memory over time. I am using PDFViewWPF.


Yes, when you call methods like those, then some resources are being allocated, that won’t be released, whether they are used or not, until PDFDoc.Save is called.

It would be best to do that sort of rendering on your own graphical layer over top of ours. In particular you can call PDFViewWPF.GetCanvas to get a canvas you can use for drawing.

At the very least reusing an existing Ink annot would be ideal, instead of calling new each time.

Additional information. There are essentially two ways to “animate” an annotation.

If you want to modify the appearance of the annotation while viewing, you need to:

  1. Write lock the document.

  2. get existing annotation.

  3. create a new appearance and set it on the annotation.

  4. tell the viewer to update the annotation rectangle.

  5. release the lock.

The other alternative, is to add your annotation as normal. And then during viewing,

  1. Read lock the document

  2. translate the annotation page coordinates to canvas coordinates

  3. using the PDFViewWPF.GetCanvas canvas, draw your own animation over top, so the actual annotation is not visible

  4. release read lock (no need to get PDFViewWPF to render anything)