With LazUTF8 simple program takes 6M more memory lazarus / 31-LCL ---------------------------------------------------------------------- AlexTP · 2020-02-09 21:32 I made empty console application (Lazarus IDE wizard made the template, I added "readln"). I takes 3M memory on Ubuntu. I added LazUTF8 to uses, and now app takes 9Mb. I cannot find what data are created in lazutf8. WideStringManager? ---------------------------------------------------------------------- marcov · 2020-02-10 09:43 Under cwstring it links to the C library, and so the C library initialization is also run. See e.g. my answer at https://stackoverflow.com/questions/11225580/does-freepascal-really- use-far-less-memory-than-gcc/11251397#11251397 ---------------------------------------------------------------------- lucamar · 2020-02-10 10:10 Even with full debugging info turned on I can't replicate your findings: from a source containing just the default "Console application" code plus a WriteLn()/ReadLn() set, the executable (Linux 32bits) is at most 1,5 MiB both before and after adding LazUTF8 to "uses" (and a project requirement for package LCLBase). In Release mode it amounts to less than 200 KiB What is your OS/Widgetset/Debug profile? That may be where the differences come from ... ---------------------------------------------------------------------- winni · 2020-02-10 10:20 Hi! Nearly the same with Linux 64 bit: 1.5 MB without LazUTF8 1.8 MB with LazUTF8 No Debugger info inside. Winni ---------------------------------------------------------------------- lucamar · 2020-02-10 11:11 Quote from: winni on February 10, 2020, 11:20:13 amNearly the same with Linux 64 bit: 1.5 MB without LazUTF8 1.8 MB with LazUTF8 No Debugger info inside. Those sizes are too high if they really have no debug info. Here is what my tests indicate for Linux-i686: Code: [Select]Without LazUTF8: ---------------- 1,2M project1-default 1,3M project1-debug 163K project1-release With LazUTF8 in uses: --------------------- 1,4M project1-default 1,5M project1-debug 187K project1-release Note that both Default and Debug modes *do* add debugging info, just different kinds (more complete in Debug). For Linux 64 bit the sizes should be just a tiny bit higher. ---------------------------------------------------------------------- marcov · 2020-02-10 11:22 He says memory use, not binary size, at least I took it as that :-) ---------------------------------------------------------------------- Cyrax · 2020-02-10 11:23 Quote from: Alextp on February 09, 2020, 10:32:34 pmI made empty console application (Lazarus IDE wizard made the template, I added "readln"). I takes 3M memory on Ubuntu. I added LazUTF8 to uses, and now app takes 9Mb. I cannot find what data are created in lazutf8. WideStringManager? In what memory you are referring to? Executable size on disk or RAM when running the program? ---------------------------------------------------------------------- lucamar · 2020-02-10 11:53 Quote from: marcov on February 10, 2020, 12:22:47 pmHe says memory use, not binary size, at least I took it as that :-) Oh! Yeah, that's quite a different thing But even so, my test uses just around 350 KiB of memory (according to the system monitor). It might be more or less depending on OS, etc. but not to such a degree, can it? ---------------------------------------------------------------------- Martin_fr · 2020-02-10 12:39 Use CMem  ? Mem allocated from OS view, and Mem used by your app can greatly differ. And that can happen with or without Utf8 units. ---------------------------------------------------------------------- AlexTP · 2020-02-10 13:34 user@PC:~$ uname -a Linux PC 5.3.0-29-generic #31-Ubuntu SMP Fri Jan 17 17:27:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux w/o "uses LazUTF8" "htop" shows VIRT=3840, RES=2056, SHR=1776 with LazUTF8 "htop" shows VIRT=9676, RES=3162, SHR=2760 This is dirung ReadLn work in app ---------------------------------------------------------------------- AlexTP · 2020-02-10 13:36 >Use CMem  ? What do you want to say? where can I use CMem and how? ---------------------------------------------------------------------- lucamar · 2020-02-10 15:58 Quote from: Alextp on February 10, 2020, 02:36:07 pm>Use CMem  ? What do you want to say? where can I use CMem and how? I guess he means that using CMem as your mem manager will pull in the C runtime libs hence explaining the bigger memory usage. Using cmem might make sense for multi-threading apps and programs making lots of allocations/dealocations because it can be fastest than the default manager but for normal programs it isn't really needed (or advisable!). ---------------------------------------------------------------------- Martin_fr · 2020-02-10 16:54 Add CMem as VERY FIRST unit to the uses of your "program name;" file. THis changes the mem manager. The fpc mem manage will allocate extra mem (so your os reports that, even if your code is not using it). Depending on how your grow/shring/allocate/free mem, the pre-allocated block can get fragmented. Note: with CMem you get also fragmentation. But AFAIK your OS will not report this as extra alloc. ---------------------------------------------------------------------- marcov · 2020-02-10 17:53 Quote from: Martin_fr on February 10, 2020, 05:54:49 pmAdd CMem as VERY FIRST unit to the uses of your "program Note: with CMem you get also fragmentation. But AFAIK your OS will not report this as extra alloc. The OS administration works on virtual pages level. It does not know if a page is x% full. So I find this highly doubtful. The term you looking for (as the true allocated size) is "private bytes". ---------------------------------------------------------------------- AlexTP · 2020-02-10 17:57 @marcov What about my numbers results above (from "htop")? ---------------------------------------------------------------------- marcov · 2020-02-10 21:04 Quote from: Alextp on February 10, 2020, 06:57:54 pm@marcov What about my numbers results above (from "htop")? Hard to say.  Res (=Resident)is probably the closest. Virtual is address space, but not necessarily mapped memory, shared are dynamic libraries shared between processes. All is probably due to libraries, and mostly external to FPC.