Redis的java客户端JRedis1.0RC退出时的bug
2011-01-26 11:14
288 查看
Redis的java版客户端有两个:JDBC-Redis 和 JRedis,听了好多评论说JDBC-Redis的性能并不怎么样,so直接使用JRedis。
在测试并发的时候,为了模拟项目实际的场景,所以每次的增读都调用一次JRedisClient的ping即建立连接操作(当然可以将客户端维护起来而不更多的建立连接,问题可能就不出现了,这里只讨论问题),如此运行几次之后,客户端抛出异常
Java代码
Exception in thread "Thread-1270" java.lang.OutOfMemoryError: Java heap space
经过查看线程数,确认是客户端中存在了很多的线程没有被关闭掉所致。
使用JRedis1.0RC版中给定的测试类HelloAgain进行DEBUG看了一下这些启动的线程,发现后台启动了一个守护线程跟Redis服务端作heartbeart,但是在执行jredis.quit()后却并没有退出,图示如下:
run的代码为:
Java代码
private void run(String password) {
try {
JRedis jredis = new JRedisClient("10.10.13.31", 6379, "jredis", 0);
jredis.ping();
if (!jredis.exists(key)) {
jredis.set(key, "Hello Again!");
System.out.format("Hello! You should run me again!/n");
} else {
String msg = toStr(jredis.get(key));
System.out.format("%s/n", msg);
}
jredis.quit(); //注意这行,方法注释为:Disconnects the client
} catch (RedisException e) {
//省略
}
}
我想这应该是bug吧,呵呵。等会再去Jredis网站上看一眼,是否对它进行了修复。。。
from: http://www.javaeye.com/topic/668657
在测试并发的时候,为了模拟项目实际的场景,所以每次的增读都调用一次JRedisClient的ping即建立连接操作(当然可以将客户端维护起来而不更多的建立连接,问题可能就不出现了,这里只讨论问题),如此运行几次之后,客户端抛出异常
Java代码
Exception in thread "Thread-1270" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Thread-1270" java.lang.OutOfMemoryError: Java heap space
经过查看线程数,确认是客户端中存在了很多的线程没有被关闭掉所致。
使用JRedis1.0RC版中给定的测试类HelloAgain进行DEBUG看了一下这些启动的线程,发现后台启动了一个守护线程跟Redis服务端作heartbeart,但是在执行jredis.quit()后却并没有退出,图示如下:
run的代码为:
Java代码
private void run(String password) {
try {
JRedis jredis = new JRedisClient("10.10.13.31", 6379, "jredis", 0);
jredis.ping();
if (!jredis.exists(key)) {
jredis.set(key, "Hello Again!");
System.out.format("Hello! You should run me again!/n");
} else {
String msg = toStr(jredis.get(key));
System.out.format("%s/n", msg);
}
jredis.quit(); //注意这行,方法注释为:Disconnects the client
} catch (RedisException e) {
//省略
}
}
private void run(String password) { try { JRedis jredis = new JRedisClient("10.10.13.31", 6379, "jredis", 0); jredis.ping(); if (!jredis.exists(key)) { jredis.set(key, "Hello Again!"); System.out.format("Hello! You should run me again!/n"); } else { String msg = toStr(jredis.get(key)); System.out.format("%s/n", msg); } jredis.quit(); //注意这行,方法注释为:Disconnects the client } catch (RedisException e) { //省略 } }
我想这应该是bug吧,呵呵。等会再去Jredis网站上看一眼,是否对它进行了修复。。。
from: http://www.javaeye.com/topic/668657
相关文章推荐
- Redis Java客户端Jredis
- 关于redis主从备份,主机拒绝写入问题 java客户端为保障正常运行该如何操作?( 自码待解决问)
- java ftp 客户端(apache jakarta commons net ftp)的bug[原创][Bug]
- 分布式缓存Redis之Java客户端
- Jredis--java使用redis
- redis在java中的客户端连接
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
- 关于JAVA的redis客户端的实现
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
- Redis系列-JAVA与redis整合-jdbc-redis的使用(存在BUG)
- Redis的Java客户端Jedis
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
- redis集群、单机java客户端API开源框架
- 从JAVA客户端访问Redis示例(入门)
- JAVA实现的异步redis客户端
- redis三种客户端:自带客户端、图形界面客户端、Java客户端
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式…)介绍
- java 客户端链接不上redis解决方案 (jedis)
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式…)介绍