当前位置:  编程技术>综合
本页文章导读:
    ▪Tomcat无法shutdown进程问题解决办法      1 问题现象 执行shutdown.sh之后,Web已经无法访问: Tomcat关联java进程仍然存活: #/home/apache-tomcat-7.0.34/bin/shutdown.sh Using CATALINA_BASE: /home/apache-tomcat-7.0.34 Using CATALINA_HOME: /home/apache-tomcat-7.0.34 Us.........
    ▪操作系统大型实验进展(5)-----C/C++语言中time_t数据类型详细介绍      包含文件: #ifndef __TIME_T #define __TIME_T     /* 避免重复定义 time_t */ typedef long     time_t;    /* 时间值time_t 为长整型的别名*/ #endif 既然time_t实际上是长.........
    ▪arm7 lpc21XX系列的IAP应用实例      /**************************************************************************** 基于arm7 lpc21XX系列的IAP应用实例 * 文件名:IAPTEST.C * 功能:LPC2100的IAP功能测试。 * 说明:调用IAP服务程序,完成FLASH编程操作。 *&nbs.........

[1]Tomcat无法shutdown进程问题解决办法
    来源: 互联网  发布时间: 2013-11-10
1 问题现象

执行shutdown.sh之后,Web已经无法访问:


Tomcat关联java进程仍然存活:

#/home/apache-tomcat-7.0.34/bin/shutdown.sh
Using CATALINA_BASE:   /home/apache-tomcat-7.0.34
Using CATALINA_HOME:   /home/apache-tomcat-7.0.34
Using CATALINA_TMPDIR: /home/apache-tomcat-7.0.34/temp
Using JRE_HOME:        /home/jdk1.6.0_34
Using CLASSPATH:       /home/apache-tomcat-7.0.34/bin/bootstrap.jar:/home/apache-tomcat-7.0.34/bin/tomcat-juli.jar
# ps aux | grep 'java.*tomcat' | grep -v grep
root     22465 15.3  8.6 1294300 346264 pts/0  Sl   14:55   1:08 /home/jdk1.6.0_34/bin/java -Djava.util.logging.config.file=/home/apache-tomcat-7.0.34/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/apache-tomcat-7.0.34/endorsed -classpath /home/apache-tomcat-7.0.34/bin/bootstrap.jar:/home/apache-tomcat-7.0.34/bin/tomcat-juli.jar -Dcatalina.base=/home/apache-tomcat-7.0.34 -Dcatalina.home=/home/apache-tomcat-7.0.34 -Djava.io.tmpdir=/home/apache-tomcat-7.0.34/temp org.apache.catalina.startup.Bootstrap start
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbccatalina.out报内存泄露警告:

严重: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Thread-2] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [thread-snatch-picture] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-0] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-1] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-2] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-3] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-4] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-5] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-6] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Xmemcached-Reactor-7] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Heal-Session-Thread] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [pool-2-thread-1] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [pool-2-thread-2] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [pool-2-thread-3] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [pool-2-thread-4] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@b6c562]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@1d97383]) 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.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@b6c562]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@9a827]) 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.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@b6c562]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@12e71f1]) 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.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@b6c562]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@855793]) 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.
2013-1-8 15:02:53 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@b6c562]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@5164df]) 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 问题分析

这个在windows下没有碰到过,因为此前跑Tomcat都是以服务而不是命令脚本的形式跑的,而且已经换了一个项目,所以暂时不考察windows下是否存在该问题。

难道是Tomcat版本问题?或者用带内存泄漏保护的Tomcat 7可以解决该问题?尝试将web应用跑在apache-tomcat-6.0.18、apache-tomcat-6.0.35、apache-tomcat-7.0.34,发现均存在无法shutdown.sh进程问题。

难道在CentOS(Linux)下,Tomcat无法用shutdown.sh停掉进程?显然不可能的。于是又把web应用从webapps中移走,换回tomcat自带的ROOT,果然启动后再shutdown.sh,查找不到原来的tomcat进程了,也就证明了是自己web应用的问题了。

3 解决方案

现在已经确定是web应用的问题了,所以可以提解决方案了。

3.1 Kill进程

忽略日志中的严重警告,因为这是关闭tomcat时候引起的,正常情况下不会发生这种内存泄露情况,而且Tomcat6.18以上版本的Tomcat已经做了内存泄露保护,交给Tomcat完成吧,我们只需要在shutdown.sh之后,补上一个kill -9 pid即可。要是嫌这样太麻烦了,可以如下这样改:

==============================bin/shutdown.sh 
exec "$PRGDIR"/"$EXECUTABLE" stop  -force "$@"  #加上 -force  
 
==============================bin/catalina.sh  
在PRGDIR=`dirname "$PRG"`后面加上
if [ -z "$CATALINA_PID" ]; then
      CATALINA_PID=$PRGDIR/CATALINA_PID
      cat $CATALINA_PI      
    
[2]操作系统大型实验进展(5)-----C/C++语言中time_t数据类型详细介绍
    来源: 互联网  发布时间: 2013-11-10
包含文件:
#ifndef __TIME_T
#define __TIME_T     /* 避免重复定义 time_t */
typedef long     time_t;    /* 时间值time_t 为长整型的别名*/
#endif
既然time_t实际上是长整型,到未来的某一天,从一个时间点(一般是1970年1月1日0时0分0秒)到那时的秒数(即日历时间)超出了长整形所能表示的数的范围怎么办?对time_t数据类型的值来说,它所表示的时间不能晚于2038年1月18日19时14分07秒。为了能够表示更久远的时间,一些编译器厂商引入了64位甚至更长的整形数来保存日历时间。比如微软在Visual C++中采用了__time64_t数据类型来保存日历时间,并通过_time64()函数来获得日历时间(而不是通过使用32位字的time()函数),这样就可以通过该数据类型保存3001年1月1日0时0分0秒(不包括该时间点)之前的时间。
在time.h头文件中,我们还可以看到一些函数,它们都是以time_t为参数类型或返回值类型的函数:
double difftime(time_t time1, time_t time0);
time_t mktime(struct tm * timeptr);
time_t time(time_t * timer);
char * asctime(const struct tm * timeptr);
char * ctime(const time_t *timer);
此外,time.h还提供了两种不同的函数将日历时间(一个用time_t表示的整数)转换为我们平时看到的把年月日时分秒分开显示的时间格式tm:
struct tm * gmtime(const time_t *timer);                                        
struct tm * localtime(const time_t * timer);
通过查阅MSDN,我们可以知道Microsoft C/C++ 7.0中时间点的值(time_t对象的值)是从1899年12月31日0时0分0秒到该时间点所经过的秒数,而其它各种版本的Microsoft C/C++和所有不同版本的Visual C++都是计算的从1970年1月1日0时0分0秒到该时间点所经过的秒数。
 
 
time_t占8位数:有图有真相
作者:chenqiai0 发表于2013-1-8 18:18:33 原文链接
阅读:70 评论:1 查看评论

    
[3]arm7 lpc21XX系列的IAP应用实例
    来源: 互联网  发布时间: 2013-11-10

/****************************************************************************

基于arm7 lpc21XX系列的IAP应用实例

* 文件名:IAPTEST.C
* 功能:LPC2100的IAP功能测试。
* 说明:调用IAP服务程序,完成FLASH编程操作。
*      将paramout添加到Watch窗口,观察返回值。
****************************************************************************/
#include "config.h"
#include "stdio.h"

#define BEEP    (1 << 22)
/* 定义IAP命令字 */
#define IAP_SELSECTOR        50
#define IAP_RAMTOFLASH       51
#define IAP_ERASESECTOR      52
#define IAP_BLANKCHK         53
#define IAP_READPARTID       54
#define IAP_BOOTCODEID       55
#define IAP_COMPARE          56

/* 定义IAP返回状态字 */
#define CMD_SUCCESS          0
#define INVALID_COMMAND      1
#define SRC_ADDR_ERROR       2
#define DST_ADDR_ERROR       3
#define SRC_ADDR_NOT_MAPPED 4
#define DST_ADDR_NOT_MAPPED 5
#define COUNT_ERROR          6
#define INVALID_SECTOR       7
#define SECTOR_NOT_BLANK     8
#define SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9
#define COMPARE_ERROR        10
#define BUSY                 11
#define PARAM_ERROR          12 /* Insufficient number of parameters */
#define ADDR_ERROR           13 /* Address not on word boundary */
#define ADDR_NOT_MAPPED      14
#define CMD_LOCKED           15 /* Command is locked */
#define INVALID_CODE         16 /* Unlock code is invalid */
#define INVALID_BAUD_RATE    17
#define INVALID_STOP_BIT     18

uint32 paramin[8];                         // IAP入口参数缓冲区
uint32 paramout[8];                        // IAP出口参数缓冲区

struct jilu
{

uint32 data;

};
struct jilu Buffer={0};
struct jilu source[10];
/****************************************************************************
* 名称:SelSector()
* 功能:IAP操作扇区选择,命令代码50。
* 入口参数:sec1        起始扇区
*          sec2        终止扇区
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 SelSector(uint8 sec1, uint8 sec2)
{ paramin[0] = IAP_SELSECTOR;              // 设置命令字
   paramin[1] = sec1;                       // 设置参数
   paramin[2] = sec2;
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}


/****************************************************************************
* 名称:RamToFlash()
* 功能:复制RAM的数据到FLASH,命令代码51。
* 入口参数:dst        目标地址,即FLASH起始地址。以512字节为分界
*          src        源地址,即RAM地址。地址必须字对齐
*          no         复制字节个数,为512/1024/4096/8192
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 RamToFlash(uint32 dst, uint32 src, uint32 no)
{ paramin[0] = IAP_RAMTOFLASH;             // 设置命令字
   paramin[1] = dst;                        // 设置参数
   paramin[2] = src;
   paramin[3] = no;
   paramin[4] = Fosc/1000;      // 当不使用PLL功能时,Fcclk=Fosc
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}


/****************************************************************************
* 名称:EraseSector()
* 功能:扇区擦除,命令代码52。
* 入口参数:sec1       起始扇区
*          sec2       终止扇区
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 EraseSector(uint8 sec1, uint8 sec2)
{ paramin[0] = IAP_ERASESECTOR;            // 设置命令字
   paramin[1] = sec1;                       // 设置参数
   paramin[2] = sec2;
   paramin[3] = Fosc/1000;      // 当不使用PLL功能时,Fcclk=Fosc
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}

/****************************************************************************
* 名称:BlankCHK()
* 功能:扇区查空,命令代码53。
* 入口参数:sec1       起始扇区
*          sec2       终止扇区
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 BlankCHK(uint8 sec1, uint8 sec2)
{ paramin[0] = IAP_BLANKCHK;               // 设置命令字
   paramin[1] = sec1;                       // 设置参数
   paramin[2] = sec2;
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}


/****************************************************************************
* 名称:ReadParID()
* 功能:扇区查空,命令代码53。
* 入口参数:无
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 ReadParID(void)
{ paramin[0] = IAP_READPARTID;             // 设置命令字
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}


/****************************************************************************
* 名称:BootCodeID()
* 功能:读取boot代码版本号,命令代码55。
* 入口参数:无
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 BootCodeID(void)
{ paramin[0] = IAP_BOOTCODEID;             // 设置命令字
   iap_entry(paramin, paramout);         // 调用IAP服务程序
   return(paramout[0]);
}


/****************************************************************************
* 名称:Compare()
* 功能:校验数据,命令代码56。
* 入口参数:dst        目标地址,即RAM/FLASH起始地址。地址必须字对齐
*          src        源地址,即FLASH/RAM地址。地址必须字对齐
*          no         复制字节个数,必须能被4整除
* 出口参数:IAP返回值(paramout缓冲区)
****************************************************************************/
uint32 Compare(uint32 dst, uint32 src, uint32 no)
{ paramin[0] = IAP_COMPARE;             

    
最新技术文章:
▪error while loading shared libraries的解決方法    ▪版本控制的极佳实践    ▪安装多个jdk,多个tomcat版本的冲突问题
▪简单选择排序算法    ▪国外 Android资源大集合 和个人学习android收藏    ▪.NET MVC 给loading数据加 ajax 等待loading效果
▪http代理工作原理(3)    ▪关注细节-TWaver Android    ▪Spring怎样把Bean实例暴露出来?
▪java写入excel2007的操作    ▪http代理工作原理(1)    ▪浅谈三层架构
▪http代理工作原理(2)    ▪解析三层架构……如何分层?    ▪linux PS命令
▪secureMRT Linux命令汉字出现乱码    ▪把C++类成员方法直接作为线程回调函数    ▪weak-and算法原理演示(wand)
▪53个要点提高PHP编程效率    ▪linux僵尸进程    ▪java 序列化到mysql数据库中
▪利用ndk编译ffmpeg    ▪活用CSS巧妙解决超长文本内容显示问题    ▪通过DBMS_RANDOM得到随机
▪CodeSmith 使用教程(8): CodeTemplate对象    ▪android4.0 进程回收机制    ▪仿天猫首页-产品分类
▪从Samples中入门IOS开发(四)------ 基于socket的...    ▪工作趣事 之 重装服务器后的网站不能正常访...    ▪java序列化学习笔记
▪Office 2010下VBA Addressof的应用    ▪一起来学ASP.NET Ajax(二)之初识ASP.NET Ajax    ▪更改CentOS yum 源为163的源
▪ORACLE 常用表达式    ▪记录一下,AS3反射功能的实现方法    ▪u盘文件系统问题
▪java设计模式-观察者模式初探    ▪MANIFEST.MF格式总结    ▪Android 4.2 Wifi Display核心分析 (一)
▪Perl 正则表达式 记忆方法    ▪.NET MVC 给loading数据加 ajax 等待laoding效果    ▪java 类之访问权限
▪extjs在myeclipse提示    ▪xml不提示问题    ▪Android应用程序运行的性能设计
▪sharepoint 2010 自定义列表启用版本记录控制 如...    ▪解决UIScrollView截获touch事件的一个极其简单有...    ▪Chain of Responsibility -- 责任链模式
▪运行skyeye缺少libbfd-2.18.50.0.2.20071001.so问题    ▪sharepoint 2010 使用sharepoint脚本STSNavigate方法实...    ▪让javascript显原型!
▪kohana基本安装配置    ▪MVVM开发模式实例解析    ▪sharepoint 2010 设置pdf文件在浏览器中访问
▪spring+hibernate+事务    ▪MyEclipse中文乱码,编码格式设置,文件编码格...    ▪struts+spring+hibernate用jquery实现数据分页异步加...
▪windows平台c++开发"麻烦"总结    ▪Android Wifi几点    ▪Myeclipse中JDBC连接池的配置
▪优化后的冒泡排序算法    ▪elasticsearch RESTful搜索引擎-(java jest 使用[入门])...    ▪MyEclipse下安装SVN插件SubEclipse的方法
▪100个windows平台C++开发错误之七编程    ▪串口转以太网模块WIZ140SR/WIZ145SR 数据手册(版...    ▪初识XML(三)Schema
▪Deep Copy VS Shallow Copy    ▪iphone游戏开发之cocos2d (七) 自定义精灵类,实...    ▪100个windows平台C++开发错误之八编程
▪C++程序的内存布局    ▪将不确定变为确定系列~Linq的批量操作靠的住...    ▪DIV始终保持在浏览器中央,兼容各浏览器版本
▪Activity生命周期管理之三——Stopping或者Restarti...    ▪《C语言参悟之旅》-读书笔记(八)    ▪C++函数参数小结
▪android Content Provider详解九    ▪简单的图片无缝滚动效果    ▪required artifact is missing.
▪c++编程风格----读书笔记(1)    ▪codeforces round 160    ▪【Visual C++】游戏开发笔记四十 浅墨DirectX教程...
▪【D3D11游戏编程】学习笔记十八:模板缓冲区...    ▪codeforces 70D 动态凸包    ▪c++编程风格----读书笔记(2)
▪Android窗口管理服务WindowManagerService计算Activity...    ▪keytool 错误: java.io.FileNotFoundException: MyAndroidKey....    ▪《HTTP权威指南》读书笔记---缓存
▪markdown    ▪[设计模式]总结    ▪网站用户行为分析在用户市场领域的应用
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3