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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:38:05+00:00 2026-06-10T10:38:05+00:00

here is my code: public void mapTrace(String Path) throws FileNotFoundException, IOException { FileReader arq

  • 0

here is my code:

 public void mapTrace(String Path) throws FileNotFoundException, IOException {
    FileReader arq = new FileReader(new File(Path));
    BufferedReader leitor = new BufferedReader(arq, 41943040);
    Integer page;
    String std;
    Integer position = 0;

    while ((std = leitor.readLine()) != null) {
        position++;
        page = Integer.parseInt(std, 16);
        LinkedList<Integer> values = map.get(page);
        if (values == null) {
            values = new LinkedList<>();
            map.put(page, values);
        }
        values.add(position);
    }

    for (LinkedList<Integer> referenceList : map.values()) { 
        Collections.reverse(referenceList); 
    }

}

This is the HashMap structure

       Map<Integer, LinkedList<Integer>> map = new HashMap<>();

For 50mb – 100mb trace files i don’t have any problem, but for bigger files i have:

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: GC overhead limit exceeded

I don’t know if the reverse method is increasing the memory use, if the LinkedList is using more space than other List structure or if the way i’m adding the list to the map is taking more space than it should. Does anyone can tell me what’s using so much space?

  • 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-10T10:38:06+00:00Added an answer on June 10, 2026 at 10:38 am

    Does anyone can tell me what’s using so much space?

    The short answer is that it is probably the space overheads of the data structure you have chosen that is using the space.

    1. By my reckoning, a LinkedList<Integer> on a 64 bit JVM uses about 48 bytes of storage per integer in the list including the integers themselves.

    2. By my reckoning, a Map<?, ?> on a 64 bit machine will use in the region of 48 bytes of storage per entry excluding the space need to represent the key and the value objects.

    Now, your trace size estimates are rather too vague for me to plug the numbers in, but I’d expect a 1.5Gb trace file to need a LOT more than 2Gb of heap.


    Given the numbers you’ve provided, a reasonable rule-of-thumb is that a trace file will occupy roughly 10 times its file size in heap memory … using the data structure that you are currently using.

    You don’t want to configure a JVM to try to use more memory than the physical RAM available. Otherwise, you are liable to push the machine into thrashing … and the operating system is liable to start killing processes. So for an 8Gb machine, I wouldn’t advise going over -Xmx8g.

    Putting that together, with an 8Gb machine you should be able to cope with a 600Mb trace file (assuming my estimates are correct), but a 1.5Gb trace file is not feasible. If you really need to handle trace files that big, my advice would be to either:

    • design and implement custom collection types for your specific use-case that use memory more efficiently,

    • rethink your algorithms so that you don’t need to hold the entire trace files in memory, or

    • get a bigger machine.


    I did some tests before reading your comment, i put -Xmx14g and processed the 600mb file, it took some minutes(about 10) but it did fine.

    The -Xmx14g option sets the maximum heap size. Based on the observed behaviour, I expect that the JVM didn’t need anywhere like that much memory … and didn’t request it from the OS. And if you’d looked at memory usage in the task manager, I expect you’d have seen numbers consistent with that.

    Then i put -Xmx18g and tried to process the 1,5gb file, and its been running for about 20 minutes. My memory in the task manager is going from 7,80 to 7,90. I wonder if this will finish, how could i use MORE memory than i have? Does it use the HD as virtual memory?

    Yes that it is what it does.

    Yes, each page of your processes virtual address space corresponds to a page on the hard disc.

    If you’ve got more virtual pages than physical memory pages, at any given time some of those virtual memory pages will live on disk only. When your application tries to use a one of those non-resident pages, the VM hardware generates an interrupt, and the operating system finds an unused page and populates it from the disc copy and then hands control back to your program. But if your application is busy, then it will have had to make that physical memory page by evicting another page. And that may have involved writing the contents of the evicted page to disc.

    The net result is that when you try to use significantly more virtual address pages than you have physical memory, the application generates lots of interrupts that result in lots of disc reads and writes. This is known as thrashing. If your system thrashes too badly, the system will spend most of its waiting for disc reads and writes to finish, and performance will drop dramatically. And on some operating systems, the OS will attempt to “fix” the problem by killing processes.

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

Sidebar

Related Questions

Here's my code: public void readFile() throws IOException { System.out.println(Input file name: ); Scanner
Here's my JFrame code: public static void main(String[] args) { JFrame jf = new
Here is my code : public static void main(String[] args) { // System.setProperty( //
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
I am testing Hibernate here is the situation and code: public static void main(String[]
Here is my code: public static String currentStudent = ; public void login() {
Here is the code: public static void main(String[] args) { SocketWorker worker = null;
here is my code public class SimpleJoglApp extends JFrame { public static void main(String[]
Here's the code: public void PrintBoletin(int studentId, int gradeParaleloId) { StudentRepository studentRepo = new
Here's the code public void findDNode(String name) { DNode u = header; while(u !=

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.