我在gwan上遇到了回复请求的问题,当我调用function xbuf_xcat(get_reply(argv), replycontent)
时,RSS值不断上升。如果我把这个函数注释掉或者改成xbuf_xcat(get_reply(argv), "value=1")
,就不会出现这种奇怪的现象了……
根 20365 0.5 0.8 403848 6468分/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.5 0.8 403848 6488 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.5 0.8 403848 6492 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.5 0.8 403848 6496 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.5 0.8 403848 6500 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.5 0.8 403848 6504 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
根 20365 0.6 0.8 403848 6504分/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
root 20365 0.6 0.8 403848 6528 pts/0 Sl+ 15:07 0:00 | _ /opt/gwan/gwan
(如果我一夜之间运行它,会消耗近 1GB 内存......)有什么
想法吗??
我修改的代码:
xbuf_t *reply = get_reply(argv);
xbuf_t f;
xbuf_init(&f);
xbuf_cat(&f,replycontent);
xbuf_ncat(reply, f.ptr, f.len);
xbuf_free(&f);
以下是代码内容:(我只是不使用我写的函数,但RSS仍然每7-10秒上升一次)
int main(int argc, char *argv[]){
printf("G-wan start Serving...\n");
char replycontent[1024];
//set replycontent value
strcpy(replycontent, "[");
int i;
for( i=0; i<2; i++){
strcpy(replycontent, "TEST ONLY");
strcat(replycontent, ",");
}
replycontent[strlen(contents)-1] = ']';
xbuf_t *reply = get_reply(argv);
xbuf_xcat(reply, replycontent);
return 200;
}
RSS 结果:
根 8170 0.3 0.7 555392 5748分/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5748 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5748 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5748 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756分/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
根 8170 0.3 0.7 555392 5756分/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 0.7 555392 5756 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 1.0 555392 7676 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 1.0 555392 7676 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 1.0 555392 7676 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
根 8170 0.3 1.0 555392 7680分/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 1.0 555392 7680 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
root 8170 0.3 1.0 555392 7684 pts/0 Sl+ 10:29 0:00 | _ /opt/gwan/gwan
如果我更改xbuf_xcat(reply, replycontent);
为printf("reply:%s\n",replycontent);
,RSS 是稳定的,但仍然会出现突然上升。