clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

addBatch method cause Java heap memory char array grows too fast

Open wangbing505 opened this issue 1 year ago • 9 comments

image The scenario involves a large number of calls to the addBatch method, Then use jmap to view heap memory,has lots of char[],although they are all unreachable objects that can be GC dropped.But it will lead to frequent GC and high CPU usage. How to solve it

wangbing505 avatar Oct 18 '24 07:10 wangbing505

Hi @wangbing505

  • What is the ClickHouse jdbc version do you use?
  • Is it a requirement to use JDBC?

chernser avatar Oct 21 '24 15:10 chernser

Hi @chernser

  1. ClickHouse jdbc version is 0.2.6,Can a higher version solve this problem?
  2. yes,or Is there any other way to write data to clickhouse ?

wangbing505 avatar Oct 23 '24 01:10 wangbing505

@wangbing505

  1. Yes, please, update to the latest 0.7.0 version. I do not see such code in it and everything should work fine.
  2. Yes, you may use java client without JDBC - https://clickhouse.com/docs/en/integrations/java/client-v2

Please let me know how the update goes. Thanks!

chernser avatar Oct 23 '24 02:10 chernser

@chernser Thank you for your answer,I will try using them and synchronize the results

wangbing505 avatar Oct 24 '24 01:10 wangbing505

@wangbing505 as the issue solved?

chernser avatar Nov 04 '24 20:11 chernser

@chernser hello, I have been delayed by other things and will try it next week

wangbing505 avatar Nov 05 '24 11:11 wangbing505

@chernser Thank you, I tried it, Char [] has decreased,But there are other memory uses as well,maybe it's not a problem with the client anymore

wangbing505 avatar Nov 07 '24 07:11 wangbing505

Need to verify how jdbc-v2 handles it.

chernser avatar Jan 09 '25 22:01 chernser

We might need to stream big SQL requests like we do with text formats. Will prioritize this work.

chernser avatar Nov 14 '25 23:11 chernser