我开发COM+的三层结构,启动MTS/COM+时的服务文件DllHost.exe
老是出现CPU占用100%的现象,
不知什么原因?
请高手指教!!!

解决方案 »

  1.   

    如果每次都这样,那你的COM+组件可能有问题。
      

  2.   

    20来秒,不是很频繁,数据库或COM+都能支持。
    我开的线程为了测试,用的是while true  :)
    看看是不是什么资源没释放?应该是程序的问题。
      

  3.   

    具体调用方法:
     with QryUDTel DO
       BEgin
          CLose;
          ParamByName('UID').AsString:=UID;
          ParamByName('Path').AsString:=ImagePath;
          ParamByName('Name').AsString:=ImageName;
          ParamByName('Tel').AsString:=Tel;
          ParamByName('Ywlx').AsInteger:=YWType;
          ParamByName('hmlx').AsString:=Hmlx;
          ParamByName('SysType').AsString:=SysType;
          ParamByName('WD').AsDateTime:=WriteDate;
          ParamByName('PageCount').AsInteger:=PageCount;
          ExecSQL;
       ENd;
       Succ:=1;
       SetComplete;
       Except
        Succ:=0;
        SetAbort;Str:String;
    f: TFileStream;
    fbuf: array[0..1024] of byte;
    fsize,asize: Integer;
    v: Variant;
    i,vi: Integer;
    VPath:String;
    begin
       Try     With QryFirstImg DO
         Begin
             CLose;
             ParamByName('UID').AsString:=UID;
             Open;
             Store:=Trim(FieldByName('Store').AsString);
             V_Path:=Trim(FieldByName('ImagePath').AsString);
             V_Name:=Trim(FieldByName('ImageName').AsString);     End;
         if (Length(Store)<>0) Then
         Begin
           IF (Length(Store)<=3) Then
           Begin
              VPath:=GetDirName(Store)+GetDirName(V_Path);
              if fileexists(Vpath+V_name) then
              begin
                try
                  f:=tfilestream.Create(Vpath+V_name,fmOpenRead);
                  fsize:=f.Size;
                  v:=vararraycreate([0,fsize-1],varByte);
                  vararraylock(v);
                  vi:=0;
                  while f.position<fsize do
                  begin
                    asize:=f.Read(fbuf,1024);
                    for i:=0 to asize-1 do
                    begin
                      v[vi]:=fbuf[i];
                      vi:=vi+1;
                    end;
                  end;
                 vararrayunlock(v);
                 image:=v;
                 ImgSize:=fsize;
                 finally
                  f.Free;
                 end;
               end       //end   if fileexists(V_path+V_name)
               else
               begin
                 Imgsize:=0;
               end;       End Else
           Begin
              IF DVD_SC.Connected=False Then
                 DVD_SC.Connected:=true;
              DVD_SC.AppServer.readStream(GetDirName(Store)+GetDirName(V_path),V_Name,image,imgsize);
           End ;
         End Else
           ImgSize:=0;
         SetComplete;
         Except
         ImgSize:=0;
         SetAbort;
         End;
       End;
      

  4.   

    在你的程序中尽量不要用事务控制,因为com+自己会处理,有可能是事务并发造成的。
      

  5.   

    根据我的经验是midas的事,在midas打数据包时对资源的瞬间占用率很高。你可以在传递数据时尽量减少数据量。
      

  6.   

    是你的客户端没有正确的创建中间层的com+/mts实例。
    这是三层开发需要掌握的基本技能。