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

  • SEARCH
  • Home
  • 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 6195327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:27:00+00:00 2026-05-24T03:27:00+00:00

I have a Java application that parses pdf files in a directory and its

  • 0

I have a Java application that parses pdf files in a directory and its subdirectories and creates a database using the information found in the files.

Everything was fine when I was using the program on around 900 files or so (which create a SQLite database with multiple tables, some of wihch contain 150k rows).

Now I’m trying to run my program on a larger set of data (around 2000 files) and at some point I get “OutOfMemoryError: Java Heap space”. I changed the following line in my jdev.conf file:

AddVMOption  -XX:MaxPermSize=256M

to 512M and I got the same error (though later, I think). I’m going to change it to something bigger again, but the thing is the computers this program will be used on are much older and thus don’t have as much memory. Normally, the users are not going to add more than 30 files at a time, but I want to know at how many files I’m supposed to limit them to. Ideally, I’d like my program not to throw an error regardless of how many files are to be parsed.

At first, I thought it was my SQLite queries that were causing the error, but after reading up on Google, it’s probably some recursive function. I isolated it (I think it’s the correct one at least), to this function:

 public static void visitAllDirsAndFiles(File dir) {
      if(dir.isDirectory()) 
      {
        String[] children = dir.list();
        for (int i=0; i<children.length; i++) 
        {
          visitAllDirsAndFiles(new File(dir, children[i]));
        }
      }
      else
      {
        try
        {          
          BowlingFilesReader.readFile(dir);
        }
        catch(Exception exc)
        {
          exc.printStackTrace();
          System.out.println("Other Exception in file: " + dir);
        }
      }
  }

I think the problem might be that it recursively calls this function for each subsequent directory, but I’m really not sure that could be the problem. What do you think? If it might be, how can I make it so I don’t get this error again? If you think it is impossible that this section alone causes the problem, I’ll try to find which other part of the program can cause it.

The only other thing I can see causing that is that I connect to the database before calling the above method and I disconnect after it returns. The reason for that is that if I connect and disconnect after each file, my programs takes a lot longer to parse the data, so I’d really like not to have to change that.

  • 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-05-24T03:27:01+00:00Added an answer on May 24, 2026 at 3:27 am

    If the origin of the problem was recursion, you would get an error related to stack instead of heap. Seems that you have some kind of memory leak in BowlingFilesReader…

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

Sidebar

Related Questions

I have a Java application that parses a large xml schema (.xsd) using Xerces
I have a Java application that monitors a folder for incoming XML files. When
I have a java application that has Web Services published using Axis. With the
I have existing Java application that is using Acegi for authentication/authorization. Our new web
I have a Java application that uses an Apache Derby database with the embedded
For my work I have to develop a small Java application that parses very
I have a java based application that manipulates a mysql database. I would like
I have a Java application that launches another java application. The launcher has a
I have a Java application that's very String-heavy - it takes a feed of
I have a java application that is connected to a view on a remote

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.