Skip to content

Memory usage rendering pdfrx 2.2.24 #604

@tc4u

Description

@tc4u

I recently upgraded my app from pdfrx 1.0.84 to 2.2.24. While everything is functioning well I noticed on both iOS and Android my app crashes when I scroll a large (500 plus) page PDF repeatedly in a PdfViewer. It's most noticeable when you add a vertical scroll thumb which allows you to quickly jump through PDF pages. Just scroll it quickly up and down 10 or 12 times. When running on my iPad the memory usage goes quickly from 300MB to 1.7GB then iOS terminates it.

I ran the page scrolling scenario through Instruments Allocations tool and found the following memory usage in the call stack below. I've verified my code is doing nothing when the PDF is scrolled. So it seems the excessive memory usage is occurring during page rendering. Around 1.3 GB as the snippet of the stack below shows.

I've seen the same crashes on both iOS and Android versions of my app doing the same scrolling test. It takes longer to crash on Android, but it still crashes eventually.

Bytes Used	  Count		  Symbol Name
1393.58 MB      87.2%	51       Timer._runTimers
1392.54 MB      87.1%	              Timer._createTimer.<anonymous closure>
1392.54 MB      87.1%	507	 	    PdfViewerState._requestRealSizePartialImage.<anonymous closure>
1392.54 MB      87.1%	507                 PdfViewerState._createRealSizePartialImage
1392.54 MB      87.1%	507	 	                  PdfPagePdfium.render
1392.03 MB      87.1%	254	 	                      MallocAllocator.allocate
1392.03 MB      87.1%	252	 	                            posixMalloc
1392.03 MB      87.1%	252	 	                                 stub CallNativeThroughSafepoint

Snapshot	Timestamp	        Growth	        # Persistent
Generation A	00:37.195.368	180.25 MiB	140486
Generation B	00:54.199.134	1.38 GiB	        28137

Generation A was taken when the 500+ page PDF was initially loaded into PDFViewer. Generation B was taken after scrolling repeatedly using the vertical scroll thumb.

Please let me know if there is anything more I can provide? Or if you need to see snippets of the code I'm using to instantiate PdfViewer. I didn't see this crash or memory usage with version 1.0.84 but I made such a large version leap I can't unfortunately pinpoint a version between when this may have surfaced.

Thank you for pdfrx and all of the work you do to make this such a great package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions