NutzCN Logo
问答 看不懂的异常 ,帮忙看看,谢谢
发布于 3342天前 作者 javanan 5328 次浏览 复制 上一个帖子 下一个帖子
标签:

1.
org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/BusinessMGTEST] created a ThreadLocal with key of type [org.nutz.mvc.NutMvcContext$1] (value [org.nutz.mvc.NutMvcContext$1@3bd8d923]) and a value of type [org.nutz.lang.util.SimpleContext] (value [{
}]) 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.

2.
严重: The web application [/GraduationProject] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
十月 28, 2015 2:17:58 下午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

3
严重: Error processing request
java.lang.NullPointerException
at org.apache.tomcat.util.buf.CharChunk.append(CharChunk.java:355)
at org.apache.tomcat.util.http.mapper.Mapper.map(Mapper.java:707)

4.
: The web application [/XingYunProject] created a ThreadLocal with key of type [org.nutz.mvc.NutMvcContext$1] (value [org.nutz.mvc.NutMvcContext$1@2f1b04ed]) and a value of type [org.nutz.lang.util.SimpleContext] (value [{

}]) 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.
十月 28, 2015 2:48:11 下午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks

29 回复

这些不是错误,只是警告

QQ图片20151029141538_png 那么这些警告是不是会导致内存泄露之类的东西 @wendal QQ图片20151029141704_png

var ioc = {
	conf : {
		type : "org.nutz.ioc.impl.PropertiesProxy",
		fields : {
			paths : [ "custom/" ]
		}
	},

	dataSource : {
		type : "com.alibaba.druid.pool.DruidDataSource",
		events : {
			create : "init",
			depose : 'close'
		},
		fields : {
			url : {
				java : "$conf.get('db.url')"
			},
			username : {
				java : "$conf.get('db.username')"
			},
			password : {
				java : "$conf.get('db.password')"
			},
			testWhileIdle : true,
			validationQuery : {
				java : "$conf.get('db.validationQuery')"
			},
			maxActive : {
				java : "$conf.get('db.maxActive')"
			},
			filters : {
				java : "$conf.get('db.filters')"
			},
			connectionProperties : {
				java : "$conf.get('db.connectionProperties')"
			}
		}
	},

	dao : {
		// NutDaoExt是为了兼容1.b.52及以下版本, 53版或以上请直接用NutDao
		type : "org.nutz.dao.impl.NutDaoExt",
		args : [ {
			refer : "dataSource"
		} ],
		fields : {
			executor : {
				refer : "cacheExecutor"
			}
		}
	},
	cacheExecutor : {
		type : "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
		fields : {
			cacheProvider : {
				refer : "cacheProvider"
			},
			cachedTableNames : [ "xy_area" ], // 需要缓存的表
			enableWhenTrans : false, // 事务作用域内是否启用,默认false
			cache4Null : true,
			// 是否缓存空值,默认true
			//DEBUG : true
		// 是否打印详细的log,默认为关

		}
	},

    // 基于Ehcache的DaoCacheProvider
    cacheProvider : {
        type : "org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider",
        fields : {
            cacheManager : {refer:"cacheManager"} // 引用ehcache.js中定义的CacheManager
        },
        events : {
            create : "init"
        }
    }

};

db.properties
db.url=jdbc:mysql://localhost:3306/xy_db?useUnicode=true&autoReconnect=true&rewriteBatchedStatements=TRUE

db.username=root
db.password=root
db.validationQuery=select 1
db.maxActive=100
db.filters=mergeStat
db.connectionProperties=druid.stat.slowSqlMillis=2000

这样配置数控连接有问题吗? 会不会存在资源没有释放问题? @wendal

除非是下面这些情况, 基本上不需要考虑上述配置的问题:

  1. 重复创建DataSource, 无论是否通过new NutIoc的方式, 只要是反复的创建DataSource实例就算
  2. 直接从DataSource取数据库连接, 而不是通过Dao接口进行操作

在查内存泄露的问题? 为啥不用Yourkit, JProfiler, Oracle Misonctor, JavaVM之类的工具, 捕风捉影有什么用

201510291344_png 数据库_png 这两种图是我GC 后 类的 使用情况,,, 我自己的应用 包检测到的实例 除了IOC管理的都被释放了, 但是 HashMap Stirng Nutz 却有很多没有被释放。

正常吗? 是不是我自己应用的一些类引用着他们导致的呢? (可是 我自己的应用 包检测到的实例 除了IOC管理的都被释放了) @wendal

在用着 Jprofiler 但是 不明白怎么用,在百度着,,,最重要的是 我还不知道什么是正常的.@wendal

@javanan 访问一万次,gc后作为基准,再访问一万次,再gc,如果内存基本不涨,基本上排除内存泄漏

我现在写了代码是

public class MemoeyTest {

	 private static int thread_num = 20;  
	    private static int client_num = 50000;  
	  
	    /**
	     * 并发模拟
	     */
	   
	    public static void main(String[] args) {  
	        ExecutorService exec = Executors.newCachedThreadPool();  
	  
	        final Semaphore semp = new Semaphore(thread_num);  
	  
	        for (int index = 0; index < client_num; index++) {  
	  
	            final int NO = index;  
	  
	            Runnable run = new Runnable() {  
	                public void run() {  
	                    try {  
	                        semp.acquire();  
	                        Response response = Http.get("http://192.168.1.120:8080/BusinessMG/linktest/link"); 
	                    
	                        System.out.println(response.toString());
	                        //业务逻辑  
	                        semp.release();  
	                    } catch (Exception e) {  
	                        e.printStackTrace();  
	                    }  
	                    try {  
	                        semp.acquire();  
	                       Map<String, Object> params=new HashMap<String,Object>();
	                       params.put("telephone", "13111976593");
	                       params.put("password", "12345678");
	                       Response response1 = Http.post2("http://192.168.1.120:8080/BusinessMG/barber/login", params, 100000); 
	                    
	                        System.out.println(response1.toString());
	                        //业务逻辑  
	                        semp.release();  
	                    } catch (Exception e) {  
	                        e.printStackTrace();  
	                    } 
	                }  
	            };  
	            exec.execute(run);  
	        }  
	        exec.shutdown();  
	    }  
}

请求很长时间后
出现错误,,

org.nutz.http.HttpException: url=http://192.168.1.120:8080/BusinessMG/linktest/link
	at org.nutz.http.sender.GetSender.send(GetSender.java:22)
	at org.nutz.http.Http.get(Http.java:58)
	at com.xy.businessmg.test.MemoeyTest$1.run(MemoeyTest.java:40)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at org.nutz.http.Sender.getResponseHeader(Sender.java:108)
	at org.nutz.http.sender.GetSender.send(GetSender.java:19)
	... 5 more
org.nutz.http.HttpException: url=http://192.168.1.120:8080/BusinessMG/barber/login
	at org.nutz.http.sender.PostSender.send(PostSender.java:38)
	at org.nutz.http.Http.post2(Http.java:75)
	at com.xy.businessmg.test.MemoeyTest$1.run(MemoeyTest.java:53)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at org.nutz.http.Sender.getResponseHeader(Sender.java:108)
	at org.nutz.http.sender.PostSender.send(PostSender.java:35)
	... 5 more

tomcat的控制台是

tomcat_png

能看出是什么问题吗? 百度说是 数据库爆满了,,但是我设置的 db.maxActive=100 Jprofiler用到的 才19个, 能看出是什么问题吗? @wendal

maxActive下面一行加一个

maxWait :15000,

这是看druid是否在等可用的连接,如果依然没有druid抛出的异常,基本上排除数据库连接耗尽。

加了maxWait :15000,

好像没有druid的异常
... 5 more
org.nutz.http.HttpException: url=http://192.168.1.120:8080/BusinessMG/linktest/link
at org.nutz.http.sender.GetSender.send(GetSender.java:22)
at org.nutz.http.Http.get(Http.java:58)
at com.xy.businessmg.test.MemoeyTest$1.run(MemoeyTest.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.nutz.http.Sender.getResponseHeader(Sender.java:108)
at org.nutz.http.sender.GetSender.send(GetSender.java:19)
... 5 more
org.nutz.http.HttpException: url=http://192.168.1.120:8080/BusinessMG/barber/login
at org.nutz.http.sender.PostSender.send(PostSender.java:38)
at org.nutz.http.Http.post2(Http.java:75)
at com.xy.businessmg.test.MemoeyTest$1.run(MemoeyTest.java:53)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.nutz.http.Sender.getResponseHeader(Sender.java:108)
at org.nutz.http.sender.PostSender.send(PostSender.java:35)
... 5 more
tomcat的错误提示 如下图
<em>~VY</em>__NT`N_OUXFTY9C6_G_png

 那不是 数据库问题? @wendal 

所以排除数据库的事咯

不过呢,感觉是tomcat自己挂了,端口耗尽了吧,如果是linux的话

是 windows的 1万次请求就端口耗尽? @wendal
这期间还出现过 这样的
java.net.SocketException: No buffer space available (maximum connections reached?): connection

不过最后挂的是
at org.nutz.http.sender.GetSender.send(GetSender.java:22)
at org.nutz.http.Http.get(Http.java:58)
at com.xy.businessmg.test.MemoeyTest$1.run(MemoeyTest.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at org.nutz.http.Sender.getResponseHeader(Sender.java:108)
at org.nutz.http.sender.GetSender.send(GetSender.java:19)
... 5 more

@wendal 

找个专业点的压力测试工具吧

@javanan 简单点就ab,高级点就jmeter

ok 我试试, 先谢啦! @wendal

在测试的时候 你们是 一个 接口一个接口的测试1000次 还是 所有接口一起加起来测试 1000次请求 @wendal

第一次上传 1W张图片后 内存使用量到 700M (图片是277k)
然后 GC 内存使用量到 122M
然后再上传1W张图片 内存使用量到900M (图片是277k)
然后在GC 检测到 内存使用量128M 这算是有内存泄露问题吗? @wendal

才涨那么一点,无视啦

想继续验证就继续跑多几十万次

恩,一张图片才 227K 100个线程循环100次, 但是 tomcat使用的内存到了900M 是不是太多了, ?@wendal

@javanan 这没意义

如果你觉得有问题, 开JProfiler看啥最多

nutz.cn 服务配置是怎么样的呢?
每天大概有多少使用量?
消耗的资源怎么样呢?@wendal

@javanan Java设置最大内存为1G,使用量?没几个人

只要不爆内存,程序爱用多少就多少呗

来自炫酷的 NutzCN

ok,非常感谢, 兽老大,对测试,或者程序开发完后的优化,有什么建议或者推荐的资源方法吗? @wendal

@javanan 本地不时跑跑profiler,服务器弄个监控,例如oneapm,免得出事都无处可查

来自炫酷的 NutzCN

@wendal ok , oneapm 我去看看,谢谢

添加回复
请先登陆
回到顶部