Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2006 Sep : TMemo.Lines.Delete(0) slow

www.cryer.info
Managed Newsgroup Archive

TMemo.Lines.Delete(0) slow

Subject:TMemo.Lines.Delete(0) slow
Posted by:"Brian Cryer" (brian.cryer@remove.127.0.0.1.this.ntlworld.com)
Date:Sat, 16 Sep 2006 11:48:09

I'm using TMemo in one of my applications to provide an activity log. For
various reasons I want to restrict the length of the log. What I'm doing is
essentially:

    memo.Lines.Add(someText);
    while Lines.Count > 50000 do
      Lines.Delete(0);

whilst this works, the delete is slow. This might not matter if I was adding
a line or two a second but I'm logging 10-100 lines a second, and having put
the above logic in my application goes from having the CPU mostly idle
(blocked waiting for data from a device) to being maxed out.

Is there a better way to do what I want to do?

thanks in advance.
--
Brian Cryer
www.cryer.co.uk/brian

Replies:

www.cryer.info
Managed Newsgroup Archive