strace

Spring Boot引起的“堆外内存泄漏”排查及经验总结

大城市里の小女人 提交于 2019-12-06 17:35:44
背景 为了更好地实现对项目的管理,我们将组内一个项目迁移到MDP框架(基于Spring Boot),随后我们就发现系统会频繁报出Swap区域使用量过高的异常。笔者被叫去帮忙查看原因,发现配置了4G堆内内存,但是实际使用的物理内存竟然高达7G,确实不正常。JVM参数配置是“-XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=256M -XX:+AlwaysPreTouch -XX:ReservedCodeCacheSize=128m -XX:InitialCodeCacheSize=128m, -Xss512k -Xmx4g -Xms4g,-XX:+UseG1GC -XX:G1HeapRegionSize=4M”,实际使用的物理内存如下图所示: 排查过程 1. 使用Java层面的工具定位内存区域(堆内内存、Code区域或者使用unsafe.allocateMemory和DirectByteBuffer申请的堆外内存) 笔者在项目中添加 -XX:NativeMemoryTracking=detail JVM参数重启项目,使用命令 jcmd pid VM.native_memory detail 查看到的内存分布如下: 发现命令显示的committed的内存小于物理内存,因为jcmd命令显示的内存包含堆内内存、Code区域、通过unsafe

Debug 利器:pstack & strace

流过昼夜 提交于 2019-12-06 13:27:29
工作中难免会遇到各种各样的 bug,对于开发环境 or 测试环境的问题还好解决,可以使用 gdb 打断点或者在代码中埋点来定位异常; 但是遇到线上的 bug 就很难受了,由于生产环境不能随意替换、中断程序,如果日志中找不到问题原因,解决问题就会很棘手 这时候就需要请出这两位 debug 利器了 ———— pstack & strace 什么是 pstack pstack 是 Linux 系统下的一个命令行工具,此命令可以显示指定进程每个线程的堆栈快照,便于排查程序异常和性能评估 pstack 是基于 gdb 实现的,通过 man pstack 可以发现,它其实是 gstack 的一个软链接 GSTACK(1) Linux Programmer's Manual GSTACK(1) 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

如何获取数据泵dm和dw进程的 Strace (Doc ID 1411563.1)

倖福魔咒の 提交于 2019-12-06 12:57:19
How To Get A Strace Of The Data Pump dm And dw Process(es) (Doc ID 1411563.1) APPLIES TO: Oracle Database - Enterprise Edition - Version 10.1.0.2 and later Information in this document applies to any platform. NOTE: In the images and/or the document content below, the user information and data used represents fictitious data. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner. GOAL This document shows how you can get an strace of the data pump dm and dw processes. 本文档说明了如何获得数据泵dm和dw进程的strace。 This may be required to be done in certain

how strace php-fpm process?

Deadly 提交于 2019-12-06 06:20:31
问题 I am using nginx+php-fpm for php environment and I want to strace the php script execute,but there are many php-fpm worker, so if how can I know which php-fpm worker is handling the script? if I should monitor all the php-fpm worker,example is as following: additional_strace_args="$1" MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process' | cut -d ' ' -f 6) while read -r pid; do if [[ $pid != $MASTER_PID ]]; then nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc

how should I use strace to snif the serial port?

梦想的初衷 提交于 2019-12-06 02:12:04
问题 I am writing an application in linux and need to access the serial port. For debugging purposes I need to snif what comes and/or goes through the serial port. I looked around and found out I can use strace to do that. So I tried the following: -I print the file_descriptor of the serial device that I use. (after restarting my application a few times, I reassured myself that the file_descriptor number my application gets from kernel is "4" -if i start my application as strace -e write=4 ./myapp

MySQL 连接时尽量使用 127.0.0.1 而不是 localhost

给你一囗甜甜゛ 提交于 2019-12-05 20:14:34
原因 Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank. localhost 使用的 Linux socket,127.0.0.1 使用的是 tcp/ip 为什么我使用 localhost 一直没出问题 因为你的本机中只有一个 mysql 进程, 如果你有一个 node1 运行在 3306, 有一个 node2 运行在 3307 mysql -u root -h localhost -P 3306 mysql -u root -h

Failure to connect to SQl Server from Linux

天涯浪子 提交于 2019-12-05 17:55:23
I am trying to connect to SQL Server 2008 on CentOS 5.8. I am using unixODBC 2.3.0 and SQL Server ODBC Driver (www.microsoft.com/en-us/download/details.aspx?id=28160). When I try to test the connection by running: isql -v mydsn username password it givens me: [S1T00][unixODBC][Microsoft][SQL Server Native Client 11.0]Login timeout expired [08001][unixODBC][Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is

How does strace read the file name of system call sys_open?

ぃ、小莉子 提交于 2019-12-05 17:14:30
I am writing a program which uses Ptrace and does the following: It reads the current eax and checks if the system call is sys_open. If it is then i need to know what are the arguments that are passed. int sys_open(const char * filename, const int mode, const int mask) So eax = 5 implies it is a open system call I came to know ebx has the address of the file location from this Question But how do I knows the length of the file name so I can read the contents in that location? I came across the following questions which address the same Question 1 Question 2 (This one is mine only!) But I still

Linux下的IO监控与分析(转)

主宰稳场 提交于 2019-12-05 14:49:15
各种IO监视工具在Linux IO 体系结构中的位置 源自 Linux Performance and Tuning Guidelines.pdf 1 系统级IO监控 iostat   iostat -xdm 1 # 个人习惯 %util 代表磁盘繁忙程度。100% 表示磁盘繁忙, 0%表示磁盘空闲。但是注意,磁盘繁忙不代表磁盘(带宽)利用率高 argrq-sz 提交给驱动层的IO请求大小,一般不小于4K,不大于max(readahead_kb, max_sectors_kb) 可用于判断当前的IO模式,一般情况下,尤其是磁盘繁忙时, 越大代表顺序,越小代表随机 svctm 一次IO请求的服务时间,对于单块盘,完全随机读时,基本在7ms左右,既寻道+旋转延迟时间 注: 各统计量之间关系 ======================================= %util = ( r/s + w/s) * svctm / 1000 # 队列长度 = 到达率 * 平均服务时间 avgrq-sz = ( rMB/s + wMB/s) * 2048 / (r/s + w/s) # 2048 为 1M / 512 ======================================= 总结: iostat 统计的是通用块层经过合并(rrqm/s, wrqm/s)后

How to decode this information from strace output

随声附和 提交于 2019-12-05 06:21:38
I wrote a small go script and traced it using strace though this script, I am trying to fetch audit messages from kernel using netlink protocol, just like like auditd. Following is the strace output on my go script- http://paste.ubuntu.com/8272760/ I am trying to find the argument that auditd provide to the sendto function. When I run strace on auditd I get following output sendto(3, "\20\0\0\0\350\3\5\0\1\0\0\0\0\0\0\0", 16, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 16 And when I strace my go file I get the following output. I am looking to decode the second argument of this