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 6763885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:31:47+00:00 2026-05-26T14:31:47+00:00

I am trying to read several big files(over 100MB). And by so far it

  • 0

I am trying to read several big files(over 100MB). And by so far it always cracks down in the middle with the OutofMemory Error. Is there any solutions to it?

           FileInputStream fstream = new FileInputStream(f);
          // Get the object of DataInputStream
        DataInputStream dain = new DataInputStream(fstream);
        //  BufferedReader br = new BufferedReader(new InputStreamReader(in));

        BufferedReader in = new BufferedReader(new InputStreamReader(dain));
        String text = in.readLine();
        while(text != null) {
            stat(text);
            text = in.readLine();
        }

The Exception is like this:

    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:2694)
at java.lang.String.<init>(String.java:234)
at java.io.BufferedReader.readLine(BufferedReader.java:349)
at java.io.BufferedReader.readLine(BufferedReader.java:382)

Here is what Stat does:

    public void stat(String text) {
    String postTypeId = this.getXmlValue(text, "PostTypeId");
    String viewCountStr = this.getXmlValue(text, "ViewCount");
    String answerCountStr = this.getXmlValue(text, "AnswerCount");
    String userId = this.getXmlValue(text, "OwnerUserId");
    String postId = this.getXmlValue(text, "Id");
    String parentId = this.getXmlValue(text, "ParentId");
    String backUpId = this.getXmlValue(text, "LastEditorUserId");
    //Add post rel
    if(parentId==null) {
        if(!postTable.containsKey(postId)) 
            postTable.put(postId, new PostRel());
    } else {
        try{
        postTable.get(parentId).addAnswer(postId);
        }catch(Exception exp) {
        }
    }
              generalCount(postTypeId,viewCountStr,answerCountStr,userId,postId,parentId,backUpId);

}

And In generalCount, I tried to insert another table:

            if(userTable.containsKey(userId)) {
        userTable.get(userId).addPost(postId);
        if(parentId!=null)
            userTable.get(userId).addAnswer(parentId);
    } else{
        UserPostInfo newInfo = new UserPostInfo();
        newInfo.addPost(postId);
        if(parentId!=null)
            newInfo.addAnswer(parentId);
        userTable.put(userId, newInfo);
  • 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-26T14:31:47+00:00Added an answer on May 26, 2026 at 2:31 pm
    1. Give the JVM more memory to work with
    2. Use less memory while reading the files (can you work with streaming data instead?)
    3. Work with memory-mapped files
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I am trying to read several line of a few files in
I have read several articles/questions/forums discussing the best auto-complete plugin for jQuery. After trying
From what I've read, this topic has come up several times over the last
I've read several posts here about ignoring files in Mercurial but I'm stumped on
I'm trying to read a text file (using perl) where each line has several
Hi guys thanks for read this. I'm trying to read several photos from a
I'm trying to merge several files with libxml2 SAX. Original files look like this:
I am using a PIC32MX534F064L ( datasheet ), and trying to read several of
I am currently trying to implement a Custom SiteMap Provider. I have read several
Trying to read an RSS and select information using Linq but can't seem to

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.