JRadke 0 Posted August 1, 2022 I use SynEdit as replacement for TMemo to list permanent incoming data. To prevent a memory overflow I limit the number of rows like this: Synedit1.Lines.Add('My new data...'); if SynEdit1.Lines.Count > 150 then SynEdit1.Lines.Delete(0); This will limit the number of rows to 150, but the allocated memory is not released by the Delete command (checked with memoryManager), so at some point I get a memory overflow. This behaviour happens since upgrading from Delphi 10.4 to Delphi 11 and SynEdit respectively (2022.03-11). Share this post Link to post
pyscripter 694 Posted August 1, 2022 (edited) Assuming you are using the Turbopack Synedit: Changes to the text buffer are undoable. So just calling Delete does not clear all related memory. You need to do one of: call ClearUndo every now and then to release the undo/redo memory. Set MaxUndo to some number to limit the undoable actions. The default is 0 (unlimited undo/redo). call LockUndo/Unlock undo to prevent actions being added to the undo/redo stack (the most efficient). If you still get a memory overflow then this is a bug that you should report. Edited August 1, 2022 by pyscripter 1 Share this post Link to post
MarkShark 27 Posted August 1, 2022 My testing with MaxUndo = 1 (to most closely match a TMemo) doesn't show any leaks. I've also tested the other scenarios with no leak issues that I could detect. It's very true that the default settings can chew through a lot of memory for the undo stuff, so in the case of a log like this you must limit or manage the undo. On a related note: Am I correct that LockUndo/UnlockUndo must always be followed by a ClearUndo in order to keep everything in sync? I wasn't' sure if that happened automatically or perhaps is just not an issue. -Mark @pyscripter I'm very impressed by how few issues there have been for such a major rewrite! Well done! Share this post Link to post
pyscripter 694 Posted August 1, 2022 (edited) You can use LockUndo to disable Undo altogether. LockUndo/UnlockUndo is also useful when you read a file or initially setup a text buffer. If the Undo buffer is not empty then you would want to call ClearUndo before or after. Edited August 1, 2022 by pyscripter Share this post Link to post
JRadke 0 Posted August 2, 2022 Thank you for the answers. The consideration of the undo/redo memory seems plausible to me, I will try that out. -Jürgen Share this post Link to post