Why is Java Fast I/O using so much memory?

Hi. My Java code that uses Fast I/O (with BufferedReader and StringTokenizer) is consuming a lot of memory for this problem - a whopping 4284 Megabytes of memory.

Here is my history of submissions for the above problem.

This is not the only problem that uses so much memory. SPOJ’s large input test problem also uses an astonishing amount of memory.

I am unable to find any evidence of such enormous memory allocation in my code - I am using a 32768 byte buffer in my BufferedReader class and 6400000 byte array to hold the given integers.

Could someone please explain this absurd memory usage?

It is due to the environment/conditions/flags under which JAVA programs are run (on judge server) that its always assigned that much memory. If you look up anybody’s JAVA submission, all are upto 4.2 GB memory. I think one of the flags was -Xdiagos verbose, you should check out their FAQ for this info.

1 Like

@vijju123 is right, it is due to the compiler flags so it affects all Java programs, not just the ones using fast I/O. You can refer to my answer here for more details. The only thing that has changed since that answer is the memory limit itself, which was set to 1280 MB earlier. This post was made inquiring about this change but sadly the admins are yet to reply.

1 Like