• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to handle memory managment in view pager

 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a app which shows a pdf files.I used view pager for this.But when i goes through pdf files it gives me below error.




How to handle memory management in view pager?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I see a NullPointerException in a method called "showTrialExpiration", my first thought is not "memory problem". Why is that your first thought?
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry ulf.below is the correct exception

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside Bitmap - so the issue is images. Make sure the images inside the PDFs are minimized. It makes no sense to have 3 MB images (as the error message says) for display on mobile devices. The quality is wasted on the small screen, and nobody wants to download large files to begin with - it takes too long and uses up mobile data allowances. You always need to think about 3G, not WiFi, when writing mobile apps.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by the way ulf i am unable to edit the pdf contents.Is there any way to handle this?I mean closing already view pages..g like that?.or somethi
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "editing"? Through all these many posts and topics you've only ever talked about displaying them.

If PDFs need to be closed/discarded/whatever depends on the API you're using for display. Make sure you do whatever it says to do. Of course, if they're in a ViewPager, if you discard them as soon as the user moves away from the page, the very next thing the user does might be to move back to the page. So you need to think about keeping the files on the device for that.
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found that we can use Pager.setOffscreenPageLimit(1); can be use for removed old pages.but it doesn't work for me
 
sam liya
Ranch Hand
Posts: 1243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ulf.I found that we have to close the open pdf files from onDestroyView() method in fragment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic