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 consumption for generated SqlObject DAO #2601
Comments
Thanks for reporting this. Yes, it's expected that Jdbi will eagerly initialize all methods for a class. This assures that if there is any serious misconfiguration, it is reported up-front, rather than failing later. That said, this does look like a fair amount of memory usage. Your screenshot doesn't quite show the whole picture: which objects actually end up holding all that memory? but we will try to look into this. |
Hi @stevenschlansker, The problem is that for each sequential Dao call, all this ConfigRegistries initialization will happen again. So moving I think, being more specific on what configs are prepared/warmed up (e.g. for called method only) or somehow caching this config in Dao object for all subsequent calls will let solve this. (Or even generation for a call fluent API-like code... ) Using JDBI with generated SqlObject is very eager on memory but good for db access code management, fluent API is much more lightweight but efficient. Memory allocation for the same 1000 calls with fluent API |
I looked for some workarounds. I created default method in the interface and implemented the call myself as
The optimization didn't work because in generated class I still have the code as:
My guess is that for default methods the generated code may call default method directly. |
Hi, I'm not sure you'll have too much luck finding workarounds - but we should be able to improve memory usage with some code improvements. I do not think we can make your suggested change to call default methods directly, at least not in all cases, because default methods may have decorating annotations like |
Hi, I'm using JDBI 3.43 and I'm using generated Dao classes. The memory consumption per call looks to be too big. The issue seems to be depending on the number of methods in Dao.
sample test
Dao looks like the one below. For the test I added just 20 similar methods.
Jdbi is configured like that:
The result in profiler is following:
It looks like generated implementation does very heavy initialization for all methods in class, even if just one method is needed in fact.
The text was updated successfully, but these errors were encountered: