Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryError: Requested array size exceeds VM limit #5

Open
StrongestNumber9 opened this issue May 24, 2023 · 4 comments
Open

OutOfMemoryError: Requested array size exceeds VM limit #5

StrongestNumber9 opened this issue May 24, 2023 · 4 comments
Assignees

Comments

@StrongestNumber9
Copy link
Contributor

StrongestNumber9 commented May 24, 2023

I was investigating a race condition with file truncation and as I was constantly writing to a file and truncating it from another thread, this happened:

Exception in thread "pool-1-thread-1" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
        at java.base/java.util.Arrays.copyOf(Arrays.java:3745)
        at java.base/java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:120)
        at java.base/java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:95)
        at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:137)
        at com.teragrep.rlo_13.MonitoredFileConsumer.readFile(MonitoredFileConsumer.java:88)
        at com.teragrep.rlo_13.MonitoredFileConsumer.accept(MonitoredFileConsumer.java:129)
        at com.teragrep.rlo_13.MonitoredFileConsumer.accept(MonitoredFileConsumer.java:32)
        at com.teragrep.rlo_12.FileTask.run(FileTask.java:63)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

Not a big file by any means:

# wc -l /tmp/rlo_13_race/log/input.txt 
122297 /tmp/rlo_13_race/log/input.txt

# du -sh /tmp/rlo_13_race/log/input.txt 
118M    /tmp/rlo_13_race/log/input.txt
@StrongestNumber9
Copy link
Contributor Author

Most likely related to #6

@StrongestNumber9
Copy link
Contributor Author

Reproduced it with if(i%10000000==0) { and Thread.sleep(5000); in the ManualRaceConditionTest

@kortemik
Copy link
Member

please check with du -h --apparent-size

       --apparent-size
              print apparent sizes rather than device usage; although the apparent size is usually smaller, it may be
              larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like

@kortemik
Copy link
Member

it is very likely that the row size exceeds the jvm memory size. please create another issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants