2

I always compile my delphi apps without 'build with runtime packages', but for my latest Project i had to use it (as it started swelling day by day ) . I use some third party VCL (TMS component pack with source code , source code directory is in search path also ),

when i compile with build with runtime packages whole bpl package is used by app in runtime (otherwise it complies only the needed vcls inside the package into the app)so i think it consumes much ram memory (normally my app uses 38 Mb ram but now 62 Mb (not only tms i have used many other vcl too )according to windows task manager).

Is there any ways to make my app consume low memory like it was compiled as single exe.

(I know to recompile the VCL packages with only needed vcl (i have the source) but it is too hard for dig the source and find out the needed vcls and sub programs)

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Vibeeshan Mahadeva
  • 7,147
  • 8
  • 52
  • 102
  • Which Task Manager column are you getting your memory readings from? – Rob Kennedy Nov 07 '10 at 16:12
  • Why are you compiling with runtime packages enabled? I'm not against it but it will surely increase the size of your installer as well, so maybe you want to rethink if it is what you want. The main benefit in memory for using this is when multiple applications run at the same time on the same machine which are built using it, with the same Delphi compiler and component versions. If it is your case, I suggest you to stop worrying about memory usage for a single application. – jachguate Nov 08 '10 at 17:13

2 Answers2

8

I think you're measuring the wrong thing. Although the package files are bigger, that doesn't necessarily mean your program is occupying more space in RAM. The compiler has to include code for all functions and units in a package, no matter which parts any given program uses, but that doesn't mean that all that code is loaded into memory. The OS will load the pages it needs; the rest will continue to reside on disk, in the BPL file it came from. The whole BPL file will occupy address space, but it won't be loaded into physical RAM, so there's not much to worry about unless you're really in danger of using the entire 2 GB of address space the OS grants your process.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • Really? I thought DLL's were loaded as memory-mapped files. And each WIN32 process has only up to 2 or 3 GB of RAM that it can address. Thus, loading big packages count against this maximum memory limit. Even though they're not actually loaded in physical RAM, they count against the limit. Right? – Wim ten Brink Nov 08 '10 at 14:48
  • Yes, really, @Workshop. What you've written is pretty much the same as what I already said. Since the whole BPL doesn't get loaded into RAM, you don't have to worry about its large size taking space away from other things you want to have in RAM. But the whole BPL *does* occupy address space, which totals 2 GB (or, rarely, 3). But you only have to worry about that if you're in danger of *needing* your entire address space, which you're probably not. – Rob Kennedy Nov 08 '10 at 15:14
0

Packages are DLLs, they need to be load into memory to work. And each package will contains the code for all the units it is built from. Thereby they can use more memory than an exe built withoyt run-time packages - although your increase looks a bit too large. On the other side, if more than your application use the same packages and they are properly installed, their code will be loaded once into memory. You could build ad-hoc packages, but you should be very careful to use different names from the standard ones or you could break some other applications, especially if you put your packages in a shared location or in a directory that comes first in the path. Before trying them, I will check that your application is not linking unused packages. Delphi will put in the options more or less all the packages it knows. You can check after a compile which packages are really used, and add them only to the package list to be used.

  • 1
    To find out what packages are really used, he has to Build (not just Compile) the project and then go to Project | Information for . – vcldeveloper Nov 07 '10 at 15:37
  • 1
    Packages are not fully loaded into memory to work. They DLLs which are page-loaded by the operating system, which loads only the pages that are actually used. – Jeroen Wiert Pluimers Nov 07 '10 at 19:38