Board index » cppbuilder » dynamic link against static link

dynamic link against static link

Hello All

    I've made my program in two versions.

1. Full dynamic build (run time too)          (exe1)
2. A Full  static build                                     (exe2)

The exe file sizes are correct, the second one is more bigger.
The strange thing :-O  at run time  exe2 file is eating much less memory
(app. 2M!!!)
then exe1!!!! Even if I run more  instances of  the exes.

How could it be???
Why are dlls (bpls) for then???)

TIA
        Hofi

 

Re:dynamic link against static link


Quote
: "Hofi" <h...@mail.ahiv.hu> wrote:
>The strange thing :-O  at run time  exe2 file is eating much less memory
>(app. 2M!!!)
>then exe1!!!! Even if I run more  instances of  the exes.

>How could it be???

Whatever you use to check this memory reports bogus values.

Quote
>Why are dlls (bpls) for then???)

They are for code sharing on disk and *in memory*. Your memory tool is
incorrect.

--
Stefan Hoffmeister (TeamB)     http://www.econos.de/
Please do apply judgement when sending email.

Re:dynamic link against static link


Stefan Hoffmeister (TeamB) <Stefan.Hoffmeis...@Econos.de> wrote in message
news:373cf320.7178552@forums.inprise.com...

Quote
> : "Hofi" <h...@mail.ahiv.hu> wrote:

> >The strange thing :-O  at run time  exe2 file is eating much less memory
> >(app. 2M!!!)
> >then exe1!!!! Even if I run more  instances of  the exes.

> >How could it be???

> Whatever you use to check this memory reports bogus values.

> >Why are dlls (bpls) for then???)

> They are for code sharing on disk and *in memory*. Your memory tool is
> incorrect.

I can not imagine that TaskManager\processes tab shows incorrect value????
Can  you?

Re:dynamic link against static link


Quote
: "Hofi" <h...@mail.ahiv.hu> wrote:
>I can not imagine that TaskManager\processes tab shows incorrect value????
>Can  you?

Yes. I even know it.

--
Stefan Hoffmeister (TeamB)     http://www.econos.de/
Please do apply judgement when sending email.

Re:dynamic link against static link


Quote
On Thu, 22 Apr 1999 11:33:35 +0200, "Hofi" <h...@mail.ahiv.hu> wrote:
>Hello All

>    I've made my program in two versions.

>1. Full dynamic build (run time too)          (exe1)
>2. A Full  static build                                     (exe2)

>The exe file sizes are correct, the second one is more bigger.
>The strange thing :-O  at run time  exe2 file is eating much less memory
>(app. 2M!!!)
>then exe1!!!! Even if I run more  instances of  the exes.

>How could it be???
>Why are dlls (bpls) for then???)

>TIA
>        Hofi

the dynamic link has to drag the huge RTL into its address space, along with all
of the memory requirements the entire RTL needs. the static version only has
part of the RTL loaded...

Re:dynamic link against static link


Quote
Hofi <h...@mail.ahiv.hu> wrote in message

news:7fmqbi$6nt1@forums.borland.com...

Quote
> Hello All

>     I've made my program in two versions.

> 1. Full dynamic build (run time too)          (exe1)
> 2. A Full  static build                                     (exe2)

> The exe file sizes are correct, the second one is more bigger.
> The strange thing :-O  at run time  exe2 file is eating much less memory
> (app. 2M!!!)
> then exe1!!!! Even if I run more  instances of  the exes.

> How could it be???
> Why are dlls (bpls) for then???)

How could it be?  Simple.  When you link with DLL's, *ALL* the code in those
DLL's (including any resources) is allocated in your applcations program
space.  Of course most of this get's swapped out so it's not really eating
much memory, but it does give you a fairly hefty footprint.

When you link statically only those routines which are used are linked into
the application.  the 90% of the code that isn't used isn't linked in and
thus doesn't load a bunch of code that you won't use (creating a smaller
memory footprint even though the EXE itself is larger).

But it really doesn't matter much either way, since unused code will be
swapped out anyways so there is little in terms of performance gain (well,
statically linked programs load faster, but that's about it).

Re:dynamic link against static link


Thanks for all of  you boys for your answers !!!!!

Quote
Erik Funkenbusch <er...@visi.com> wrote in message

news:7fottq$86512@forums.borland.com...
Quote
> Hofi <h...@mail.ahiv.hu> wrote in message
> news:7fmqbi$6nt1@forums.borland.com...

 > The strange thing :-O  at run time  exe2 file is eating much less memory
Quote
> > (app. 2M!!!)
> > then exe1!!!! Even if I run more  instances of  the exes.

> > How could it be???
> > Why are dlls (bpls) for then???)

> How could it be?  Simple.  When you link with DLL's, *ALL* the code in
those
> DLL's (including any resources) is allocated in your applcations program
> space.  Of course most of this get's swapped out so it's not really eating
> much memory, but it does give you a fairly hefty footprint.
> When you link statically only those routines which are used are linked
into
> the application.  the 90% of the code that isn't used isn't linked in and
> thus doesn't load a bunch of code that you won't use (creating a smaller
> memory footprint even though the EXE itself is larger).

OK. I can understand it. Only one thing I can not. I thought that the main
advantage of using DLLs
is that you can save memory, because the next running instance of your
program (or another which using the same DLLs) will use the code of the
previously loaded moduls. It does not seem to me happened!?!?
(May be I missunderstood  the VM and Mem columns of the
TaskManager\Processes tab)
Will you make it a little bit clearer for me????

TIA
        Hofi

Re:dynamic link against static link


Quote
Hofi <h...@mail.ahiv.hu> wrote in message

news:7fp4l7$85h19@forums.borland.com...

Quote
> OK. I can understand it. Only one thing I can not. I thought that the main
> advantage of using DLLs
> is that you can save memory, because the next running instance of your
> program (or another which using the same DLLs) will use the code of the
> previously loaded moduls. It does not seem to me happened!?!?
> (May be I missunderstood  the VM and Mem columns of the
> TaskManager\Processes tab)
> Will you make it a little bit clearer for me????

Yes and no.  DLL's save disk space since the code only has to be on disk
once.  DLL's also save physical (as opposed to virtual) memory as well since
one copy of the code can be physically loaded into memory (note that this is
only code segments and read-only data segments.  read/write memory will be
unique for each process that loads a DLL).  But each program has to "see"
the memory in order to access it, thus it has to be mapped into that
processes address space.  The same code can exist once in physical memory
and look like multiple copies to each process that's looking at it.

These are really moot points today anyways since memory and disk space are
so abundant.  The real advantage to DLL's is the fact that code can be
updated simply by replacing the DLL rather than in 20 different
applications.  It's also easier to develop large programs if functionality
is broken up into different DLL's.

DLL's can also give certain advantages.  Fixing a bug in an application that
uses DLL versions of the borland runtimes means shipping a smaller updated
file rather than a larger one (for downloading purposes).

Re:dynamic link against static link


Thank you I'm starting to understand it ;)
thank again

Hofi

Quote
Erik Funkenbusch <er...@visi.com> wrote in message

news:7fp6n4$86030@forums.borland.com...
Quote
> Hofi <h...@mail.ahiv.hu> wrote in message
> news:7fp4l7$85h19@forums.borland.com...

.
.
.
Quote
> DLL's can also give certain advantages.  Fixing a bug in an application
that
> uses DLL versions of the borland runtimes means shipping a smaller updated
> file rather than a larger one (for downloading purposes).

Re:dynamic link against static link


This has been my suspicion for some time. Can you point to a more reliable
method of assessing memory usage?
Quote
"Stefan Hoffmeister (TeamB)" wrote:
> : "Hofi" <h...@mail.ahiv.hu> wrote:

> >I can not imagine that TaskManager\processes tab shows incorrect value????
> >Can  you?

> Yes. I even know it.

> --
> Stefan Hoffmeister (TeamB)     http://www.econos.de/
> Please do apply judgement when sending email.

Other Threads