Druid version

	<dependency>
	    <groupId>com.alibaba</groupId>
	    <artifactId>druid</artifactId>
	    <version>1.0.16</version>
	</dependency>
Copy the code

The phenomenon of 😣

When I woke up in the morning, I saw that all the alarms in the alarm group were from project to FullGC, including some OOM alarms. There were even two Tomcats that were not online.

The fault is not caused by external requests. The project starts a thread in the background to consume the message queue.

Dealing with problems 🌲

Look at instance objects

Something’s wrong, but I don’t see anything.

Look at the stack

Stack analysis using the jStack generation yielded nothing. Very few threads are in Runnable.. According to does not contain this data

Dump 😂

Jmap -dump:live,format=b,file=pid.hprof pid

usematOpen the dump file and you can see it intuitivelyWhat the hell is taking up so much, rightIncoming 和 OutcomingIt’s a mess. I can’t tell

Switch to JProfiler (just download and play, feel similar to mat, beautiful interface)

Open dump down to the hprof file. Pretty much what the MAT shows. com.alibaba.druid.stata.JdbcDataSourceStat$1It’s amazing how much this includes, as experienced developers knowThe $1Is an instance class inside a class. Let me give you an example.

The source file

Compiled class files…

Open theideaLet’s start looking at this class.Where is itputThe data ofIt’s pretty clear up here, because of configurationDataSourcewhenFilterConfigure thestatParameter. Quickly remove the publish line.

The next day, a steady batch of..

conclusion

This dump file is not easy to read. I wonder if I can find the stack entry, various points, from this object, but there are none, so I think 🤔 is the wrong direction. That won’t be the case next time.

The Filter is used to view data in the interface. It can be turned off if you do not view or have other ways to view SQL.

thinking

Under what circumstances does sqlStatMap clean up data? What caused the Map to accumulate so much data?

After the link

Github.com/alibaba/dru…