[tmp]$ ps -ef | grep java
root 9787 1 0 Sep17 ?00:02:48 /opt/IBM/WebSphere/AppServer/java/bin/java -Xms50m -Xmx256m
-Xms 和 -Xmx 分别代表分配JVM的最小内存和最大内存。
堆栈信息你可以用 kill -3 后面跟上java进程的pid,这样就能生成 thread dump 了。
方法一:pstack pidNAME
pstack - print a stack trace of a running process
SYNOPSIS
pstack pid
DESCRIPTION
pstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case
unless you have run strip(1)), then symbolic addresses are printed as well.
If the process is part of a thread group, then pstack will print out a stack trace for each of the threads in the group.
SEE ALSO
nm(1), ptrace(2), gdb(1)
方法二:gstack pid
NAME
gstack - print a stack trace of a running process
SYNOPSIS
gstack pid
DESCRIPTION
gstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case
unless you have run strip(1)), then symbolic addresses are printed as well.
If the process is part of a thread group, then gstack will print out a stack trace for each of the threads in the group.
SEE ALSO
nm(1), ptrace(2), gdb(1)
方法三:
使用gdb 然后attach 进程ID,然后再使用命令 thread apply all bt。
方法一和方法二一样,方法三可以查看更多的信息。
查看进程在Linux要检查那一个进程(process)占用特定埠号,可以用netstat或lsof来做,例如想列出所有开启的埠号,可以netstat指令:
假如只想输出某个文件的进程,可以加上grep过滤:
或者只想输出占用某个端口的进程,可以加上grep过滤:
上面可以看到是mongod占用端口966,进程的pid是966
杀死进程通常有两个命令来结束进程:
kill - 通过进程 ID 来结束进程
killall - 通过进程名字来结束进程
我们现在用 kill 命令来杀死 mongod的进程。这个命令的结构是:kill SIGNAL PID
或者:
我们已经知道我们想要杀死的那个进程的名字,我们能够利用 killall 命令发送同样的信号,像这样:
killall -9 mongod
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)