0

I'm getting the following EdwsActivePrograms exception when IdwsProgram and IdwsProgramExecution variables are defined globally:

TDelphiWebScript instance "dws" still has 1 active IdwsProgram instance(s)

Steps to reproduce based on the example below: Start the application, hit Button1, then Button2, and finally close the application. The exception pops up when I close the application.

var
  prog : IdwsProgram;
  exec : IdwsProgramExecution;

procedure TForm1.Button1Click(Sender: TObject);
begin
  prog := dws.Compile('begin'#13#10'end;');
  if prog.Msgs.Count = 0 then
    exec := prog.BeginNewExecution;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  exec.EndProgram;
end;

In above example dws is a TDelphiWebScript component dropped on the form. My goal is to reuse IdwsProgramExecution instance in the application. Running on Delphi 10.1 and latest DWScript sources.

Vlad
  • 43
  • 6
  • After calling `exec.EndProgram` you are not setting `exec` or `prog` to nil, so those objects are still in memory. Try setting them to nil before exiting the application. – Remy Lebeau Sep 11 '17 at 21:25
  • 1
    Thank you Remy, that solved the issue, both must be set to nil. – Vlad Sep 13 '17 at 06:44

0 Answers0