我写了一个golang程序,它在运行时使用1.2GB的内存.
调用go tool pprof http://10.10.58.118:8601/debug/pprof/heap只有323.4MB堆使用量的转储结果.
使用gcvis我得到这个:

..和这个堆形式配置文件:

这是我的代码:https://github.com/sharewind/push-server/blob/v3/broker
我无法直接访问目标主机,需要ssh作为代理.
如何从本地使用ssh杀死进程?我试试这个:
ssh root@$center "ssh root@$ip \"ps -ef|grep -v grep|grep $target_dir/$main|awk '{print \$2}'|xargs kill\""
Run Code Online (Sandbox Code Playgroud)
它有错误:
kill: can't find process "root"
Run Code Online (Sandbox Code Playgroud)
如何避免过程不存在的错误?
我想反转一个字符串,但我在swap char上出错了.
有人可以帮我吗?
char* reverse_char(char* src){
char *p,*q;
p = q = src;
while(*(p) != '\0'){
p++;
}
p--;
char temp = '\0';
while (p > q) {
temp = *p;
*p = *q; // I got exec bad access here ??? why
*q = temp;
p--;
q++;
}
return src;
}
Run Code Online (Sandbox Code Playgroud)
这是主要方法.
int main(int argc, char const* argv[])
{
char *hi = "hello world!\n";
printf("%s", hi);
reverse_char(hi);
printf("%s", hi);
return 0;
}
Run Code Online (Sandbox Code Playgroud)