Recent

Author Topic: SynEdit and ATSynEdit clearing lines  (Read 1221 times)

TomTom

  • Full Member
  • ***
  • Posts: 109
SynEdit and ATSynEdit clearing lines
« on: January 10, 2019, 12:25:18 pm »
What is the correct cleaning method for all lines in ATSynEdit and SynEdit? This is not completely clear to me.
I've done tests and for example, when I enter about 855,000 lines to SynEdit, TaskManager shows that my program uses about 170MB RAM. When I use SynEdit.Clear, the memory consumption drops to about 30MB RAM and the program just after running without adding text to SynEdit takes about 3MB RAM. How do you check what takes 23MB? Or how to release all unnecessary memory?
The same applies to ATSynEdit.

After emptying the ClipBoard, memory usage also decreases but only slightly

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5466
    • wiki
Re: SynEdit and ATSynEdit clearing lines
« Reply #1 on: January 10, 2019, 01:13:08 pm »
This is normal for any FPC application.
FPC has a memory manager between your code and the OS.

Your code (and either edit, or any other component request memory from fpc.
Fpc allocates huge chunks from the OS, and then hands them to the code. If the code frees them, the fpc mem mgr, keeps them for later re-use. So your OS does not see this.

This is normally no problem, because every app has its own mem space. The "idle" memory will be swapped to disk and done.
Only if you have no swap space at all on your disk, then this behaviour may be an issue...

On linux, you can use CMem (add as the first entry to the "uses" clause of your "program" / not "uses" of "unit", but "program").

Bart

  • Hero Member
  • *****
  • Posts: 3452
    • Bart en Mariska's Webstek
Re: SynEdit and ATSynEdit clearing lines
« Reply #2 on: January 10, 2019, 01:26:53 pm »
CMem is supposed to work unde Windows as well.

Bart

TomTom

  • Full Member
  • ***
  • Posts: 109
Re: SynEdit and ATSynEdit clearing lines
« Reply #3 on: January 10, 2019, 01:30:16 pm »
Oh now it's clear :) Thank You for explaining this to me :)
I could not decide what to use in the project (ATSynEdit or SynEdit). In the second one I miss only WordWrap (and maybe MultiCaret) but I think I can live without it. Using SynEdit is much more simple :)

Thanks again :)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5466
    • wiki
Re: SynEdit and ATSynEdit clearing lines
« Reply #4 on: January 10, 2019, 01:59:18 pm »
TSynEdit indeed has no word wrap.

But it does have multi caret. It comes as a plugin and currently cannot be added via the designer. You need to add it in your code.

Code: Pascal  [Select]
  1.   TSynPluginMultiCaret.Create(SynEdit);

I have no experience with AtSynEdit, so I can not compare.
And as the maintainer of TSynEdit, I might be biased anyway....
« Last Edit: January 10, 2019, 02:01:29 pm by Martin_fr »

TomTom

  • Full Member
  • ***
  • Posts: 109
Re: SynEdit and ATSynEdit clearing lines
« Reply #5 on: January 10, 2019, 02:38:27 pm »
Oh my! I love being newbie,  because I learn so many awesome things every day ;) In that case, SynEdit is just right for my needs :)
Thank You so much :) Is there a place where Can I read about other things that can't be added via the designer?



TSynEdit indeed has no word wrap.

But it does have multi caret. It comes as a plugin and currently cannot be added via the designer. You need to add it in your code.

Code: Pascal  [Select]
  1.   TSynPluginMultiCaret.Create(SynEdit);

I have no experience with AtSynEdit, so I can not compare.
And as the maintainer of TSynEdit, I might be biased anyway....

lucamar

  • Hero Member
  • *****
  • Posts: 1824
Re: SynEdit and ATSynEdit clearing lines
« Reply #6 on: January 10, 2019, 03:05:28 pm »
Is there a place where Can I read about other things that can't be added via the designer?

The help files, online documentation, the wiki, external code sites, ... and, of course, source diving into the rtl, fcl, lcl, packages, etc.

It may take some time but you'll end up knowing at least how and where to start searching for something you need. :)
« Last Edit: January 10, 2019, 03:07:01 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4 & 2.0.2 w/FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

TomTom

  • Full Member
  • ***
  • Posts: 109
Re: SynEdit and ATSynEdit clearing lines
« Reply #7 on: January 10, 2019, 03:21:55 pm »
@lucamar
This is my biggest problem :). Since my native language is not English, I often just do not know what to look for: P or how to ask about things I don't know :).
Ofcourse I look in source code of what I'm using but for now it's not always easy to understand.






Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5466
    • wiki
Re: SynEdit and ATSynEdit clearing lines
« Reply #8 on: January 10, 2019, 03:25:57 pm »
There is a lack of docs for SynEdit.

But you can:
- check the file ide/sourceSynEditor => it adds plug-ins to the synedit for the IDE.
- example folder (eg various completion plug-ins)
- check files in the synedit folder => unit names give a clue
  *Plugin*    various
  *Markup*  highlights not bound to a specific language
- http://wiki.lazarus.freepascal.org/SynEdit
  Some features have there own wiki page (eg multi caret)

There is a basic macro recorder.
The units for the pascal script macros are a separate package

The LazarusCCR has extra highlighters
There is a tutorial (example folder/wiki) to write your own HL.

Ask here ;)

TomTom

  • Full Member
  • ***
  • Posts: 109
Re: SynEdit and ATSynEdit clearing lines
« Reply #9 on: January 10, 2019, 08:33:48 pm »
Ok so I have one more question :)
I have clean Lazarus 1.8.4 + FPC3.04 instalation.

When I add SynEdit to uses clause by hand and just run my application I get

Code: [Select]
Kompilowany projekt, Obiekt docelowy: C:\Users\Tomek\AppData\Local\Temp\project1.exe: Kod wyjścia 1,Błędy: 1,
unit1.pas(8,31) Fatal: Can't find unit SynEdit used by Unit1

But when I add SynEdit1  to the Form and then delete it everthing is ok. Ofcourse I can do that every time but I wonder why this happens.
Is it possible to, I don't know, configure something so I can just add SynEdit to uses clause by hand and then also by hand create SynEdit and put it on the form?

 



howardpc

  • Hero Member
  • *****
  • Posts: 3043
Re: SynEdit and ATSynEdit clearing lines
« Reply #10 on: January 10, 2019, 09:20:02 pm »
In the project inspector add SynEdit as a dependency to your project.
 In the project inspector window, Click on the +Add toolbutton, and click on the New Requirement menu item.
This opens the New Requirement window. Type syn in the Package Name filter box, select SynEdit in the list of packages and click OK.

When you drop a SynEdit component on the form, the IDE does all this for you behind the scenes. It is part of what "Integrated" means in "Integrated Development Environment".