Jena leaves mem.FourTupleMap and mem.FourTupleMap.ThreeTupleMap when web application shuts dows

Viewed 35

Greeting Jena gurus

I wrote a small Jersey (3.0.3) web app loading a model created from a bunch of static files into memory dataset (Jena 4.2.0)

ds = DatasetFactory.createTxnMem();
Model m = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RDFS_INF);

then, bunch of

RDFDataMgr.read(m, f.getAbsolutePath());

and finally

Reasoner owl = ReasonerRegistry.getOWLReasoner();       
ds.setDefaultModel(ModelFactory.createInfModel(owl, m));

The small web app, running in Tomcat 10 basically just query this database and return bits of the dataset content in various formats. But I have the problem even before I get to the querying part (ie. I start the app and shutdown before querying)

The loading of the dataset (above) happens at ServletContextListener.contextInitialized stage and I think I do a proper close at contextDestroyed. The Dataset stored in a singleton and when the lights go down

TDBFactory.release(ds);
ds.close();

but, in the logs, I get a list when I shutdown the application

24-Oct-2021 12:40:23.743 SEVERE [Thread-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [gsip] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value
[java.lang.ThreadLocal$SuppliedThreadLocal@3ddefd3b]) and a value of type [org.apache.jena.sparql.core.mem.FourTupleMap.ThreeTupleMap] (value [org.apache.jena.sparql.core.mem.FourTupleMap$ThreeTupleMap@4f7ca31b]) but failed to remove it
when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
24-Oct-2021 12:40:23.747 SEVERE [Thread-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [gsip] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value
[java.lang.ThreadLocal$SuppliedThreadLocal@3ddefd3b]) and a value of type [org.apache.jena.sparql.core.mem.FourTupleMap.ThreeTupleMap] (value [org.apache.jena.sparql.core.mem.FourTupleMap$ThreeTupleMap@4f7ca31b]) but failed to remove it
when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

note, (not sure it's relevant) there are 2 types:

org.apache.jena.sparql.core.mem.FourTupleMap.ThreeTupleMap and org.apache.jena.sparql.core.mem.FourTupleMap , always 1 of the former for 2 of the latter. Just loading the dataset creates 3 mem.FourTupleMap.ThreeTupleMap and 6 mem.FourTupleMap

The list will grow with more interaction, but seems to top at 99.

I have the same issue inside eclipse (Windows 10, jdk 15) or in docker (using tomcat:jre11-openjdk-slim-buster)

Any hints of what I'm doing wrong ?

Thanks

0 Answers
Related