-
Notifications
You must be signed in to change notification settings - Fork 826
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
Memory leak in QueryExecutorImpl #1431
Comments
@atuldaemon is it possible to test this against 42.2.5 ? |
The decoderArray used in decoding UTF8 strings is now kept constant to 1024 bytes. If the input size is larger than 1024 bytes, then only the cdata is allocated to a larger value instead of increasing the size of decodeArray. This helps keeping the size/memory to a constant.
Is this issue fixed in any newer version? We are facing the same issue in 42.2.2 version. Memory is allocated and is never returned back.
|
Any chance you can test it with a newer version ? |
Sure. I will test it on 42.2.6 |
The latest is 42.2.12 |
@anshum17 , I guess your case is different. I would suggest try the following:
|
Sorry to use that old issue but I feel like I have a memory issue with my project and I know I have some extremely long queries because I insert or update a field with a very long string. |
Why do you think you have this issue? When you say long. How big? |
Actually, I'm not sure if it's this issue specifically or this one : #1360 Here is what brought me on the pgjdbc repo : |
Well we don't have a concrete plan on how to remove the finalizer, but I suppose we can create a new branch and provide snapshot if you can test it ? |
What would be the point of testing a snapshot if in the end the finalizer won't be removed ? 😅 |
To find out if that is the real issue. We currently don't have a way to replicate it. I'm fairly certain finalizer will be going away once we figure out if/how to replace it. |
I've prepared a fix to reduce the heap overhead of finalizers and prevent locking the finalizer thread in #2817 git clone --depth 10 --branch reduce_finalize_overhead https://github.com/vlsi/pgjdbc.git pgjdbc_reduce_finalize_overhead
cd pgjdbc_reduce_finalize_overhead
# It will publish to the local maven repository
./gradlew :postgresql:publishToMavenLocal
# It will prepare `pgjdbc/build/libs/postgresql-42.6.0-SNAPSHOT-all.jar` and `postgresql-42.6.0-SNAPSHOT-osgi.jar`
./gradlew :postgresql:osgiJar |
…d StreamWrapper Previously, an abandoned PgConnection could retain a significant amount of heap. Now the bare minimum is moved to a separate class, so the abandoned connections can be removed from the heap earlier. This does not remove the use of `.finalize()`, and it only reduces the amount of retained heap memory. Fixes pgjdbc#1431 Fixes pgjdbc#1360
I'm submitting a ...
Describe the issue
The JDBC driver does not free up memory when reading large text from the DB. The memory leak happens in UTF8 decoding where the size of the decoderArray remains unbounded. The decoderArray is increased but is never shrunken if processing large strings.
Driver Version?
42.2.2
Java Version?
1.8
OS Version?
Ubuntu
PostgreSQL Version?
10.4 (Ubuntu 10.4-2.pgdg14.04+1)
To Reproduce
Here is a sample program to demonstrate the problem.
If we take a heap dump at (1) and compare it with the heap dump at (2), then we will see that QueryExecutorImpl takes as much more memory as the size of the text column retrieved in rs.getString() and this memory never gets returned back even after stmt.close and conn.close
The reason for this is that the decoderArray in UTF8Encoding.java is expanded, but never shrunken back to its initial size of 1024, when it has to decode texts greater than 1024 size.
Expected behaviour
The memory footprint of the driver should remain constant. Here we see that the memory footprint increases but never goes back to its initial state.
Logs
Here is one of the heapdumps that I profiled using yourkit
The text was updated successfully, but these errors were encountered: