日期:2014-05-16  浏览次数:20632 次

linux下用gsoap,内存增长
在linux下用gsoap访问webservice
res=SoapBind.ns1__query(strToken,strResult); //类似的webservice接口,得到结果在string strResult中

ns1_query是gsoap自动生成的C接口函数
在循环
while(1)
{
  res=SoapBind.ns1__query(strToken,strResult);
}
通过死循环不断访问webservice,程序都很正常,访问得到的结果都是正确的,但是发现内存使用率不断增长,而且确实是由于
SoapBind.ns1__query(strToken,strResult);
访问webservice造成的,我现在的猜想是用gsoap访问webservice的时候,函数内有申请内存将结果缓存下,每次循环结束内存就增长而且增长量相对固定
问下,有什么办法来解决内存增长,怕内存泄露

------解决方案--------------------
gsoap 缓存数组最大值 100,000,达到最大后会自动清理缓冲区

#ifndef SOAP_MAXARRAYSIZE
# define SOAP_MAXARRAYSIZE (100000) /* "trusted" max size of inbound SOAP array for compound array allocation */
#endif