I'm opening a large PDF and using DrawPageToDC on each page. I want to make sure that after drawing each page I clear as much overhead memory as possible. Here's what I'm currently doing.
hr := PXCV_DrawPageToDC(FDocID, APage - 1, B.Canvas.Handle, @AParams);
PXCV_ReleasePageCachedData(FDocID, APage - 1, pxvrcd_ReleaseDocumentImages);
PXCV_ReleaseCachedData(FDocID, pxvrcd_ReleaseDocumentImages);
PXCV_ReleaseCachedData(FDocID, pxvrcd_ReleaseDocumentFonts);
QUESTION: I'm not sure I follow completely what PXCV_ReleasePageCachedData and PXCV_ReleaseCachedData do. As such, can you tell me how I should call these two functions to ensure removing as much overhead as possible that comes from calling PXCV_DrawPageToDC.
Thanks.
PXCV_ReleaseCachedData
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
-
- Site Admin
- Posts: 3550
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: PXCV_ReleaseCachedData
PXCV_ReleaseCachedData releases memory used by parsed pages' contents, fonts and images. PXCV_ReleasePageCachedData does the same, but just for resources used by the specified page. You can use just one call to release as much memory as it is possible:
Also you can add pxvrcd_ReleaseGlobalFonts flag, which will release memory used by system fonts used for rendering the PDF page.
Code: Select all
PXCV_ReleaseCachedData(FDocID, pxvrcd_ReleaseDocumentImages + pxvrcd_ReleaseDocumentFonts);
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 914
- Joined: Wed Sep 30, 2009 6:53 pm
Re: PXCV_ReleaseCachedData
Perfect. I'll use all three flags.
-
- Site Admin
- Posts: 17949
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
-
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: PXCV_ReleaseCachedData
Hi jeffp.
Good solution for your case:
HTH
Good solution for your case:
Code: Select all
for (int i = 0; i < pagesCount; ++)
{
PXCV_DrawPageToDC(docID, i, hDC, pParams);
PXCV_ReleasePageCachedData(docID, i, pxvrcd_ReleaseDocumentImages);
if ((i % 20) == 0) // release document's fonts after each 20 pages (one font can be used on more pages, releasing document's fonts after drawing of each page - not effective solution)
{
PXCV_ReleaseCachedData(docID, pxvrcd_ReleaseDocumentFonts);
}
}
PXCV_ReleaseCachedData(docID, pxvrcd_ReleaseDocumentImages | pxvrcd_ReleaseDocumentFonts);
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.