On 2022-02-04 7:49 PM, Steven White wrote:
Hi everyone,
This simple code, is causing me memory and thread loak (threads remain in
"sleeping" mode):
for (int j = 0; j < 10000; j++)
{
SolrClient solrClient = new
HttpSolrClient.Builder("foo-bar").build();
}
Any idea why? Is there an unbuild(), release() or something I have to call?
You need to nuke the JVM from orbit, it's the only way to be sure.
TL;DR: all the memory and threads consumed by your new HttpSolrClient's
will be released sometime between when you stop using them and JVM exit.
It's a feature, not a bug, of all garbage-collected runtimes.
(Reference-counting ones like python VM have it a bit better but there's
still no guarantee the garbage collector will free a particular object
when you want it to.)
Dima