我是jstat工具的新手.因此,我做了如下的样本.
./jstat -gcutil -t 4001 5000
Timestamp S0 S1 E O P YGC YGCT FGC FGCT GCT
565088.4 0.00 0.89 75.86 40.59 84.80 405 3.822 4 0.549 4.371
565093.4 0.00 0.89 77.81 40.59 84.80 405 3.822 4 0.549 4.371
565098.4 0.00 0.89 77.81 40.59 84.80 405 3.822 4 0.549 4.371
565103.5 0.00 0.89 77.85 40.59 84.80 405 3.822 4 0.549 4.371
565108.5 0.00 0.89 77.85 40.59 84.80 405 3.822 4 0.549 4.371
565113.4 0.00 0.89 77.85 40.59 84.80 405 3.822 …Run Code Online (Sandbox Code Playgroud) 我已经使用该工具运行了我的一个堆文件,下面是 Leak Hunter 的结果。嫌疑人 2 我猜是由于我正在池化的性质,所以连接一直有效。我无法很好地理解嫌疑犯 1,因为当我按下详细信息时,它会给出一长串以下详细信息
java.lang.ref.Finalizer @ 0xf5e19670 40 92,688
next java.lang.ref.Finalizer @ 0xf5e1a6a8 40 93,024
next java.lang.ref.Finalizer @ 0xf5e1bda0 40 122,768
Suspect 1.
The class "java.lang.ref.Finalizer", loaded by "<system class loader>", occupies 1,337,176 (30.93%) bytes. The memory is accumulated in one instance of "java.lang.ref.Finalizer" loaded by "<system class loader>".
Keywords
java.lang.ref.Finalizer
Suspect 2
6 instances of "com.mysql.jdbc.JDBC4Connection", loaded by "sun.misc.Launcher$ExtClassLoader @ 0xf58bf000" occupy 432,624 (10.01%) bytes.
Biggest instances:
•com.mysql.jdbc.JDBC4Connection @ 0xf61c54f8 - 94,864 (2.19%) bytes.
•com.mysql.jdbc.JDBC4Connection @ …Run Code Online (Sandbox Code Playgroud) 大家好我们已经开始使用事务范围,下面是代码片段.我们需要了解的是,在每次使用连接后,我们的底线是否会处理/关闭特定连接?所以,自关闭以来,transaction.complete如何运作?
using (TransactionScope transScope = new TransactionScope())
{
try
{
string myConnStringLocal = "User Id=***;Password=****;Host=" + globalSettings.settingLocalIP + ";Database=" + globalSettings.settingLocalDB;
using (MySqlConnection connectionLocal = new MySqlConnection(myConnStringLocal))
{
try{
connectionLocal.Open();
}
Catch(Exception e)
{
}
finally{
connectionLocal.Close();
}
}
string myConnStringCentral = "User Id=***;Password=*****;Host=" + globalSettings.settingCentralIP + ";Database=" + globalSettings.settingCentralDB;
using (MySqlConnection connectionCentral = new MySqlConnection(myConnStringCentral))
{
try{
connectionCentral.Open();
}
Catch(Exception e)
{
}
finally{
connectionCentral.Close();
}
}
string myConnStringCentralCopy = "User Id=*****;Password=*****;Host=" + globalSettings.settingCentralCopyIP + ";Database=" + globalSettings.settingCentralCopyDB;
using …Run Code Online (Sandbox Code Playgroud) 我们有套接字应用程序发出相当多的电子邮件.所以我们决定向它发送大量的消息,这将触发电子邮件.最终我们看到电子邮件需要几个小时才能到达任何收件箱gmail,hotmail或yahoo等.我们在开头有这个代码.
public class commuSe {
BoneCP connectionPool = null;
class ConnectionHandler implements Runnable {
private Socket receivedSocketConn1;
ConnectionHandler(Socket receivedSocketConn1) {
this.receivedSocketConn1=receivedSocketConn1;
}
public void run() {
.....
}
void sendClientEmail(String emailMessageString)
{
try
{
Properties props = new Properties();
props.put("mail.smtp.host", "**********");
props.put("mail.smtp.socketFactory.port", "******");
//props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "*****");
Session session = Session.getDefaultInstance(props,new javax.mail.Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("*********","*******");
}
});
int count=0;
System.out.println("\n\nClient Email queue took ready :"+emailMessageString);
try
{
String[] eMArray = null;
eMArray = emailMessageString.split("@EmL@"); …Run Code Online (Sandbox Code Playgroud)