Hi,I found that there are many mappers that cause fullgc。

<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.4.4</version> </dependency> MyBatis fullgc in 3.4.4

Comment From: harawata

Please let us know how we can reproduce the problem.

Comment From: LUAgam

There should be enough mappers in the project and mapper inherits baseMapper.This is not easy to reproduce MyBatis fullgc in 3.4.4

MyBatis fullgc in 3.4.4

MyBatis fullgc in 3.4.4

Comment From: LUAgam

I guess it is because there are too many mappedStatements in static variable configuration in DefaultSqlSessionFactory, resulting in memory leak

Comment From: harawata

Thank you for the follow-up, @LUAgam .

Parsing mappers is a resource consuming task, but it usually is not a problem because it's done only once during application startup. If you, for example, rebuild Configuration repeatedly in your application, it might cause performance issue, so don't do that. Another example is automated testing. If mappers are parsed many times during test phase, it might cause such problem.

Is there any possibility that the mappers are parsed repeatedly in your case?

Comment From: LUAgam

Thank you for the follow-up, @LUAgam .

Parsing mappers is a resource consuming task, but it usually is not a problem because it's done only once during application startup. If you, for example, rebuild Configuration repeatedly in your application, it might cause performance issue, so don't do that. Another example is automated testing. If mappers are parsed many times during test phase, it might cause such problem.

Is there any possibility that the mappers are parsed repeatedly in your case?

No repeat generation, just too many mappers

Comment From: harawata

So, it just occurs only during the startup of your application, is that correct?

Comment From: LUAgam

So, it just occurs only during the startup of your application, is that correct?

I analyzed the dump while the program was running, which showed that oom came from the hashMap in mybatis. According to the source code location, it should be caused by too many statements when the project started

Comment From: harawata

Oh, there is OutOfMemoryError? Please post the full stack trace.

Comment From: LUAgam

Oh, there is OutOfMemoryError? Please post the full stack trace.

may be,This is the result of MAT analysis MyBatis fullgc in 3.4.4

Comment From: harawata

Thanks, however that image just shows that Configuration#mappedStatements consumed a lot of memory. And you also posted another image which implied that there were actually many mappers, so if you didn't allocate enough memory (with -Xmx), experiencing full GC or OutOfMemoryError might be expected.

I would try to improve MyBatis code if there is any inefficiency, but so far, there is no clue about where to look at.

When a similar issue #743 was reported, for example, the full GC occurred only with a newer version of MyBatis, so we knew there was something wrong. And we could finally find the problem because a user provided a project reproducing the issue.

Could you please try to create a new project with a lot of dummy mappers similar to yours and see if it reproduces the problem?

Comment From: harawata

No reply.