-
Notifications
You must be signed in to change notification settings - Fork 418
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 javacpp-presets-libpostal libpostal_expand_address method #641
Comments
@saudet FYI |
Ran a few parser tests under valgrind with no memory leaks found on this side. Can you write the above test program in C, compile it, and run under Not clear on how javacpp-presets interacts with the C functions (it does not use the official jpostal/JNI bindings, instead generating its own automatic JNI bindings from the C API), and whether it's using latest or a tag. If it's not using the latest version of libpostal, would recommend trying that as there were some SSE fixes recently, but none of those were related to a memory leak. Also noting that libpostal is not thread-safe so should only be used from a single thread. |
@albarrentine thank you for the quick response. The program can be found in the following github repo , with instruction in the ReadMe file of how to run it. In the memory leak report I found these two reoccurring stack trace leaks :
it looks like in both cases it is related to the @saudet for clarification could you please shed some light as to how the JNI binding works including the used libostal version, and if the stack trace above could be related to this memory leak issue? In addition I attached bellow a java NTM report which shows that the memory leak is not relevant to the JVM managed memory space, and also the report provided by the macOS leaks util Please let me know if you need any more information. |
@orividrisk Your small example is pretty big. If you're serious about debugging this, reduce it down to only a few lines. |
@orividrisk https://github.com/orividrisk/libpostal-poc/blob/bd583351594b729dfa2bb89c6fac8f4ffb67c37d/src/main/java/com/example/test/Address.java#L66 you’re not calling libpostal_address_parser_response_destroy to free the memory allocated in that line, which explains both 1 and 2. |
@albarrentine adding In our production env we are using both address normalization & parsing which both presented with memory leak issue. The following is a call stack example of a leak for the macOS leaks util:
For the normalized address I didn't see a method to "destroy" the returned normalized string. I updated the example github repo to now perform both parsing and normalization. The README instructions in the repo can be used to reproduce the issue, with the detailed leaks instances report printed out to console after the process concludes it's run. normalized address leak report.txt Please let me know if you need any more information. |
@orividrisk there's a corresponding function |
Hi,
When using the javacpp-presets-libpostal libpostal 1.1-1.5.8 I experience a memory leak in my java process.
My code is iterating on a large number of addresses, and over time the java process memory is increasing until it crashes due to OOM.
I have been monitored the jvm heap and non heap memory metrics and there is no issue there.
This leads me to the conclusion that the issue is with the native allocation of the returned address response, which is not deallocating the parsed addresses.
I created an issue in the
javacpp-presets
repo (mentioned in the libpostal readme), where they replied that it could be a potential libpostal c library memory leak:bytedeco/javacpp-presets#1407
The following is my code (I am using the default options provided by the library):
If any more information is needed I would be happy to provide it.
I would very appreciate your prompt assistance with the issue as it is having a big impact on our production env.
Thank you and have a very nice day.
The text was updated successfully, but these errors were encountered: