[JAVA-186] Memory Leak Created: 12/Oct/10  Updated: 29/Oct/10  Resolved: 12/Oct/10

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eli Fox-Epstein Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File foo.java    

 Description   

Run this https://gist.github.com/b905d59e9af00a7ad33f to reproduce.

Java eats up all of its heap then tries to GC over and over again without freeing up any memory.

I think that the problem is in BasicOutputBuffer.



 Comments   
Comment by Henrik Johansson [ 13/Oct/10 ]

You are right of course!
I can't believe I didn't see this!

Its the internal queue in the executor that grows endlessly due to the endless while loop.

Well, a reality check every now and then can't hurt!

Comment by Eliot Horowitz (Inactive) [ 12/Oct/10 ]

Please see foo.java attached.
When I run there is no leak nor any increase in gc or memory usage.

Comment by Henrik Johansson [ 12/Oct/10 ]

Not sure that that is the whole story, replacing the tasks with a single runnable produces the same result.
There are only 2 threads and increasing them speeds up the pace even

Giving the JVM a large amount of memory does not help. Time between GC approaches 0 as execution time grows after which it blows up.

Removing the mongodb code from the runnable and increasing the memory makes it perform a full GC every second but still die with oom after a while.

I think that its just too fast so the GC can't cope.

Still Eliot please remove the explicit calls to gc() in the driver.

Comment by Eliot Horowitz (Inactive) [ 12/Oct/10 ]

Running your test through a profiler, the issue is you create an infinite number of worker tasks.
Since that grows unbounded, it uses all the ram

Generated at Thu Feb 08 08:51:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.