GC_FOR_ALLOC on Android jump to page

Hi,

I’m testing your PDFNet Android Library for displaying Pdfs in my layout. I also integrated a slider which shows an overview about all pages. I have a couple of Pdfs here, which have about 200-300 pages. When i jump from the first pages to pages 200-300 (PdfViewCtrl.setCurrentPage(…)), i get many GC_FOR_ALLOC logs. I think it tries to free/allocate new memory. This makes the whole activity slow and on user inputs the activity has lags. I don’t really know why this is happening, tries it to cache all the pages? I appreciate any help.

Thanks

Hi Peter,

PDFViewCtrl will try to cache the content. However, thecache size can be controlled using PDFNet.setViewerCache:

https://www.pdftron.com/pdfnet/mobile/docs/Android/pdftron/PDF/PDFNet.html#setViewerCache(int, boolean)

The GC_FOR_ALLOC flags are for rendering the page. After rendering finished, it should not have any more GC_FOR_ALLOC flags.
If there’s a particular document that is very slow, please send us the file and we can take a look. But while rendering it does need to allocate more memory.

“whole activity slow and on user inputs the activity has lags”

What kind of user inputs is this referring to?

The following needs to be called in the Activity’s life cycle.

`
@Override
protected void onPause() {
super.onPause();
if (mPDFView != null) {
mPDFView.pause();
}
}

@Override
protected void onResume() {
super.onResume();
if (mPDFView != null) {
mPDFView.resume();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
if (mPDFView != null) {
mPDFView.destroy();
mPDFView = null;
}
}

public void onLowMemory() {
super.onLowMemory();
if (mPDFView != null) {
mPDFView.purgeMemory();
}
}
`

Hi,

thanks for the hint with setViewerCache(). I played a little around with the parameter. Could not figure out yet, what values are best. Do you have any empirical values for less powerful tablet devices?
I have also played with the rendered content cache size ( PdfViewCtrl.setRenderedContentCacheSize(…)) and reached a good user experience with setting it to 0.25 * allowedMax…The old Nexus 7 2012 has a worse performance than the N7 2013. I also figured out that the smaller the rendered content cache size is, the longer it takes to render a single page. This leads for the first milli sec. to a blurred font. This also happens on zooming.

About your question with user inputs,
i mean user inputs like zooming, swiping pages and showing/ hiding my pages thumbnail preview with all pages at the bottom of my viewer layout. The animation stutters a little bit.
Am Freitag, 5. Dezember 2014 11:22:03 UTC+1 schrieb Peter:

Hi,

I’m testing your PDFNet Android Library for displaying Pdfs in my layout. I also integrated a slider which shows an overview about all pages. I have a couple of Pdfs here, which have about 200-300 pages. When i jump from the first pages to pages 200-300 (PdfViewCtrl.setCurrentPage(…)), i get many GC_FOR_ALLOC logs. I think it tries to free/allocate new memory. This makes the whole activity slow and on user inputs the activity has lags. I don’t really know why this is happening, tries it to cache all the pages? I appreciate any help.

Thanks

Hi,

setViewerCache and setRenderedContentCacheSize are doing different things:

PDFNet.setViewerCache:
This is useful if the document contains many large images that takes long time to render. If you are concerned about memory usage, you can try set on_disk to true so that the cache will be stored in local file system instead. (see documentation)

PDFViewCtrl.setRenderedContentCacheSize:

This controls how mush off screen content that it should render (i.e. invisible content above and below the current screen), the larger the value, the viewer will have a better viewing experience when scrolling. (see documentation)

You can also take a look at the CompleteReader sample provided in the package for sample usage.