Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:05:55+00:00 2026-06-15T19:05:55+00:00

I am developing a simple pdf reader rewriting an existing example. My app has

  • 0

I am developing a simple pdf reader rewriting an existing example.
My app has a custom view with two buttons next and previous. When the next button is clicked it downloads a pdf from the internet and shows it in the view. Each time the next or previous button is clicked the following showPdf() method is called.

public void showPdf(){

    RelativeLayout lout = (RelativeLayout)LayoutInflater.from(this).inflate(R.layout.main, null);
setContentView( lout );
m_vPDF = null;
m_vPDF = (PDFReader)lout.findViewById(R.id.PDFView);

m_vPDF.open( m_doc);


m_vPDF.setViewListener(m_vPDF);

LinearLayout bar_find = (LinearLayout)lout.findViewById(R.id.bar_find);
     //
btn_prev = (Button)bar_find.findViewById(R.id.btn_prev);
btn_next = (Button)bar_find.findViewById(R.id.btn_next);
//        
btn_prev.setOnClickListener(this);
btn_next.setOnClickListener(this);
}

PDFReader is the object that has a viewer to show PDFs. Following is a part of the PDFReader code.

public class PDFReader extends View implements PDFView.PDFViewListener,  

    ThumbView.ThumbListener
{

private PDFView m_viewer = null;

public PDFReader(Context context)
{
    super(context);
}
public PDFReader(Context context, AttributeSet attrs)
{
    super(context, attrs);
}
public void set_viewer( int view_style )
{

    switch( view_style )
    {
    case 1:
        m_viewer = new PDFViewHorz();
        break;
    case 2:
        m_viewer = new PDFViewScroll();
        break;
    case 3:
        m_viewer = new PDFViewSingle();
        break;
    case 4:
        m_viewer = new PDFViewSingleEx();
        break;
    case 5:
        m_viewer = new PDFViewReflow();
        break;
    default:
        m_viewer = new PDFViewVert();
        break;
    }
    if( m_viewer != null )
    {
        if( doc != null ) m_viewer.viewOpen(getContext(), doc, 0xFFCC0000, 4);
        m_viewer.viewSetAnnotListener( annot_listener );
        m_viewer.viewSetViewListener( view_listener );
        m_viewer.viewResize(getWidth(), getHeight());
        if( pos != null ) m_viewer.viewGoto(pos);
    }
}

In my showPdf I initialize PDFReader each time a button is clicked and inside PDFReader an instance for PDFView is initialized with PDFViewVert object and never garbage collected even if set the PDFReader to null and PDFView to null.
As a result it is causing outofmemory error.

This is the memory analysis of dump which shows 14 instances of PDFViewVert have been created and never deallocated.

14 instances of "com.radaee.pdfex.PDFViewVert$1", loaded by "dalvik.system.PathClassLoader @ 0x412a0b08" occupy 19,602,792 (64.39%) bytes.

Biggest instances:

com.radaee.pdfex.PDFViewVert$1 @ 0x412a1ae8 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x412c7c30 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x418bdf78 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x41a382f8 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x41a4df50 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x41eaf1c0 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x4202a8e0 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x421aaa10 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x4233dbf8 - 1,543,040 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x412a0bf0 - 1,543,024 (5.07%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x412bbf58 - 1,390,792 (4.57%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x412f0790 - 1,390,792 (4.57%) bytes.
com.radaee.pdfex.PDFViewVert$1 @ 0x424c4b50 - 1,390,792 (4.57%) bytes.


Keywords
com.radaee.pdfex.PDFViewVert$1
dalvik.system.PathClassLoader @ 0x412a0b08

Any help is appreciated..
Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:05:56+00:00Added an answer on June 15, 2026 at 7:05 pm

    Try with this :

    Runtime.getRuntime().gc();
    

    Change this

    m_vPDF = null;
    

    To,

    if (m_vPDF != null){
      m_vPDF.recycle();
      m_vPDF = null;
    }
    

    This will helps you to clean unused objects.

    Hope it helps you.

    Thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing simple CUDA app. I followed steps given on http://www.ademiller.com/blogs/tech/2010/10/visual-studio-2010-adding-intellisense-support-for-cuda-c/ but still there
I'm developing an application in PyQt4 that eventually has to open and show PDF
I'm developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding)
I'm developing a simple Qt 4 app and making my own dialog. I subclassed
I'm developing a simple epub reader on iPhone but been wondering how to go
I am new to iphone app developing and need to display a PDF file
I'm developing simple video recording app for Android 2.2+ and having trouble with getting
I'm developing simple android application, using Media Player to play sound. It has a
I am developing simple producer-consumer example. One thread records audio samples using AudioRecord class
I am developing a simple app which updates its tile time to time. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.