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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:04:32+00:00 2026-05-11T19:04:32+00:00

I am reading in a text file using FileInputStream that puts the file contents

  • 0

I am reading in a text file using FileInputStream that puts the file contents into a byte array. I then convert the byte array into a String using new String(byte).

Once I have the string I’m using String.split("\n") to split the file into a String array and then taking that string array and parsing it by doing a String.split(",") and hold the contents in an Arraylist.

I have a 200MB+ file and it is running out of memory when I start the JVM up with a 1GB of memory. I know I must be doing something in correctly somewhere, I’m just not sure if the way I’m parsing is incorrect or the data structure I’m using.

It is also taking me about 12 seconds to parse the file which seems like a lot of time. Can anyone point out what I may be doing that is causing me to run out of memory and what may be causing my program to run slow?

The contents of the file look as shown below:

"12334", "100", "1.233", "TEST", "TEXT", "1234"
"12334", "100", "1.233", "TEST", "TEXT", "1234"
.
.
.
"12334", "100", "1.233", "TEST", "TEXT", "1234"

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-05-11T19:04:33+00:00Added an answer on May 11, 2026 at 7:04 pm

    It sounds like you’re doing something wrong to me – a whole lotta object creation going on.

    How representative is that “test” file? What are you really doing with that data? If that’s typical of what you really have, I’d say there’s lots of repetition in that data.

    If it’s all going to be in Strings anyway, start with a BufferedReader to read each line. Pre-allocate that List to a size that’s close to what you need so you don’t waste resources adding to it each time. Split each of those lines at the comma; be sure to strip off the double quotes.

    You might want to ask yourself: “Why do I need this whole file in memory all at once?” Can you read a little, process a little, and never have the whole thing in memory at once? Only you know your problem well enough to answer.

    Maybe you can fire up jvisualvm if you have JDK 6 and see what’s going on with memory. That would be a great clue.

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

Sidebar

Ask A Question

Stats

  • Questions 111k
  • Answers 111k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can put both functions into a single separate file… May 11, 2026 at 9:40 pm
  • Editorial Team
    Editorial Team added an answer I believe you mean Why does const imply internal linkage… May 11, 2026 at 9:40 pm
  • Editorial Team
    Editorial Team added an answer You can pass-through class attribute: <asp:BulletedList ID="BulletedList1" runat="server"> <asp:ListItem class="1">SomeText</asp:ListItem>… May 11, 2026 at 9:40 pm

Related Questions

I am reading a text file with this format: grrr,some text,45.4321,54.22134 I just have
I'm reading in a large text file with 1.4 million lines that is 24
I am using D6 Professional and need to create a text file in a
I'm writing a program where performance is quite important, but not critical. Currently I
In this tutorial I am reading , Dave Ward creates a page that shows

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.