请问大牛们,我每次在执行idhttp.get程序的句柄就会增加,请问如何解决?
      //执行下载文件
      astream:=TFileStream.Create(LoadRoute+'\'+filename+'.dm',fmCreate);
      http:=TIdHTTP.Create(nil);
      http.Get(aurl,astream);
      //下载完毕后释放http、astream内存
      if http.Connected then
        http.Disconnect;
      if Assigned(http) then
        http.Free;
      if Assigned(astream) then
      begin
        freeandnil(astream);
      end;

解决方案 »

  1.   

    这个是create和free的问题,当free后,socket连接要等一会才断开。所以看到有N多的连接。
    如果动态建立,最好create写到initialization里面,free写到finalization里面。这样就只有一个idhttp存在。
      

  2.   

    回复楼上,我做的是ocx程序,在ie里使用,我的作业流程是这样的,create->get->get->get....->get->free也就是只有一个idhttp存在,但是每次get的时候,ie的句柄一直在增加。如何解决这样的问题
      

  3.   

    有可能是在ocx,idhttp就会出现get的时候,句柄会增加的情况。我模拟了exe和ocx同样代码,exe不断get句柄只有第一次会增加一次,但是ocx,也就是ie里,每次get,ie的句柄都会增加一。
      

  4.   

    我试验了ie和猎豹浏览器,结果猎豹浏览器的句柄稳定,而ie就一直蹭蹭蹭的往上涨
      

  5.   

    astream:=TFileStream.Create(LoadRoute+'\'+filename+'.dm',fmCreate);       http:=TIdHTTP.Create(nil); 
    try
     http.Get(aurl,astream);       //下载完毕后释放http、astream内存 
     if http.Connected then  
       http.Disconnect;    
    except
    end;
    if Assigned(http) then      
       http.Free;  
    if Assigned(astream) then     
    begin     
      freeandnil(astream);     
    end; 
      

  6.   

    顶,我试验了几遍,每次执行idhttp.get方法ie浏览器的句柄数量就增加,但是使用别的浏览器运行我的ocx程序的时候,浏览器句柄数量不变。这样的现象有人遇到吗?