做的几个OCX控件,在网页同一页面里调用,第一个链接打开后总是正确的,后面的就会出现Access violate ……之类的错误,怀疑是没有释放内存问题,但是自己在程序中只是用了一些简单的控件(如Timage\Tedit\Tlabel等)、(动态)数组等,这些要释放吗?如果要释放,用free还是dispose?是在destroy事件中写释放吗?

解决方案 »

  1.   

    我再destroy事件中对动态数组执行:=nil,但是在ie关闭时destroy事件并不执行?我的初始化的代码是
    procedure TActiveFormX.Initialize;
    var
       i:integer;
    const
       mystring='edit';
    begin
      inherited Initialize;
      OnActivate := ActivateEvent;
      OnClick := ClickEvent;
      OnCreate := CreateEvent;
      OnDblClick := DblClickEvent;
      OnDeactivate := DeactivateEvent;
      OnDestroy := DestroyEvent;
      OnKeyPress := KeyPressEvent;
      OnPaint := PaintEvent; 
      edit24.Color:=clyellow;
      edit24.Left:=shape1.Left+1;  edit24.Width:=shape1.Width-2;
      edit24.Height:=20;  edit25.Color:=clyellow;
      edit25.Left:=shape2.Left+1;
      edit25.Width:=shape2.Width-2;
      edit25.Height:=20;  for i:=4 to 13 do
        begin
          tedit(findcomponent(mystring+inttostr(i))).Color:=clskyblue;
          tedit(findcomponent(mystring+inttostr(i))).Left:=shape1.Left+1;
          tedit(findcomponent(mystring+inttostr(i))).Top:=shape1.top+20*(i-4);
          tedit(findcomponent(mystring+inttostr(i))).Width:=shape1.Width-2;
          tedit(findcomponent(mystring+inttostr(i))).Height:=20;
          tedit(findcomponent(mystring+inttostr(i))).Visible:=false;
          tedit(findcomponent(mystring+inttostr(i))).Text:='';
        end;
      for i:=14 to 23 do
        begin
          tedit(findcomponent(mystring+inttostr(i))).Color:=clskyblue;
          tedit(findcomponent(mystring+inttostr(i))).Left:=shape2.Left+1;
          tedit(findcomponent(mystring+inttostr(i))).Top:=shape1.top+20*(i-14);
          tedit(findcomponent(mystring+inttostr(i))).Width:=shape2.Width-2;
          tedit(findcomponent(mystring+inttostr(i))).Height:=20;
          tedit(findcomponent(mystring+inttostr(i))).Visible:=false;
          tedit(findcomponent(mystring+inttostr(i))).Text:='';
        end;
        edit24.Top:=edit13.Top;
        edit25.Top:=edit23.Top;
        label4.Height:=25;
        label4.Width:=185;
        label5.Height:=25;
        label5.Width:=185;
        trackbar1.Position:=2;
        label6.Top:=0;
        label6.Left:=0;
        label6.Width:=920;
        label6.Height:= 75;    listbox1.ScrollWidth:=800;
        listbox2.ScrollWidth:=800;     end;
    请问有什么资源要释放吗?