Thanks a lot for both of the replies. I tried testing with the different codes. Originally I was using the memo_name.clear;
So I tried running it with the same stuff pasted into the memo and with that timer in each (timing the clearing of the memo) and also timing the appearance of the new form (using a watch) after pressing Ctrl G.
The 1st time into the new form (when the memo is already empty) with memo_name.clear shows time taken to clear the memo as 00:00.000 and is about immediately loaded.
After pressing the button to process records and that finishing and the form closing and other processing finishing:
The 2nd time into the new form (when the memo had text in the memo) still with the FormShow with memo_name.clear, shows the time taken to clear the memo as either 00:00.004 or 00:00.005 (and takes about 15 secs for the form to appear).
--
The 1st time into the new form (when the memo is already empty) with beginupdate, lines.clear, endupdate, showed 00:00.001 as the time taken for clearing the memo.
The 2nd time into the new form (when the memo had text into the memo) with beginupdate, lines.clear and endupdate, showed 00:00.002 as the time taken for clearing the memo and the form took about 13 secs to appear).
--
Using memo.text:='';
The 1st time into the new form (when the memo was already empty): shows 00:00.000 as the time taken to clear the memo.
The 2nd time into the new form (when it had text in the memo before clearing it): shows 0:00.005 as the time taken to clear the memo and took about 13 secs for the form to appear.
So if my stopping of the stopwatch on my watch is right, those 2 seem to have reduced the time taken for the new form to appear the 2nd time by about 2 secs,
but still taking around 13 secs is quite a long time.
As of these tests for this post the debug option in the project options is set to "Dwarf with sets (-gw godwarfsets)" - I don't know if that makes any difference.
If the end figure in the time taken for the clearing of the memo is showing under a second in each that's probably meaning it can't really be the memo clearing that's the main issue (even though that's the only thing that happens in the FormShow event of the new form (apart from the new timer code to time it and display the time taken). But the first time of loading the new form (when the memo in it was already empty and before we've pressed any buttons later in that new form to process lots of records) was when it loads it instantly.
Could it be anything to do with the different debug options?
Or could past processing not have really stopped even though it's past the end of it and shown that it has with a showmessage saying it has (ie. if Lazarus does something in the background)?
Could Lazarus be doing it's own processing for some other reason (eg. garbage collection? or flushing some file buffers - even though previous processing should have stopped since it showed a message I put in that said that it had finished in the previous procedure?)?
I've checked and it definitely isn't doing anything much before the call to open the new form (when the past processing should already have been stopped).
ie. menu option to call the new form at the start just:
added_or_updated:=false; // sets a global variable
frm_the_new_form_name.showmodal();
showmessage('after showmodal'); // so never gets here until after the new form has
// been closed, so anything after this isn't what's
// causing the slowdown.
----
And in the new form that gets called (after selecting the option or pressing Control G),
the FormCreate procedure is empty.
and the FormShow just has the timer code and display and the memo clearing.
eg.
var t: tdatetime;
begin
t:=now;
// the_memo.clear;
// bits commented out so I could try the different ways of clearing it
{ the_memo.Lines.BeginUpdate;
the_memo.Lines.Clear;
the_memo.Lines.EndUpdate;
}
the_memo.text:='';
ShowMessage(FormatDateTime('nn:ss.zzz', Now - t));
end;
[Edited to add code tags; please read
How to use the Forum.]
Edited to add the timings for
on its own (without the BeginUpdate and EndUpdate)
---
With the_memo.lines.clear (without beginupdate and endupdate);
1st time into new form: shows 00:00.000 as time taken to clear the memo. The new form appeared immediately after pressing Ctrl+G to show it.
2nd time into new form (when there had been something in the memo and past processing should have stopped): shows 00:00.002 as the time taken to clear the memo and the form appeared about 13 secs after pressing Ctrl+G to display it.