Loading and Unloading of generated Classes

Our application does not use a static set of models. We deploy additional models during runtime instead. We do this using the com.mgmtp.a12.dataservices.client.model.ModelsClient API of DataServices.
Usually, one large Document Model is added together with some additional models (Form, Tree, Overview, etc.).
If these parts of the application are not needed later on, the models (and all the documents that are based on these models) will be deleted and maybe replaced with other models.

In our performance tests, where we do these operations extensively, we noticed a constant increase of the Non-Heap Memory in the Metaspace. We see the following behaviour:

  • We deploy new models and start using them (by creating new documents out of these models)
  • This apparently leads to a bunch of classes being loaded by the JVM. I guess these are the generated classes for the Document Model and must be considered normal
  • After we delete the models, the total amount of loaded classes drops a little but nowhere near to the “original level”. Only a restart of Data Services brings the amount of loaded classes and the corresponding Metaspace size to the original level

To illustrate the problem, two screenshots of our monitoring showing the count of loaded classes and the metaspace size:
2e1f6f01023ee978

The two large increases represent two test runs where we deployed a larger amount of models (but nothing extraordinary for our use case). Afterwards, all deployed models where deleted. But as you can see, not much happened.

This might lead to memory issues at some point when the application is heavily used and has longer uptime.
Is this considered normal behaviour of A12, or are we missing some special setting (caching or something), that prevents classes from being unloaded?

hey @eduard-polar-knoll,
sorry for the late reply! I’ve involved our data services team and they will head back to you here soon

HI @eduard-polar-knoll,

please create an A12 ticket for this with all the models and DS configurations that you are using and DS version. We will take a look. From the first glance, it indeed looks like possible leak. There are 2 levels of model caches, and we need to investigate what is the source of this.

Cheers,
Tomas

Hi @tomas-thin-gale,

I created A12-15823. Just let me know, if you need more information.

Cheers,
Eduard