Subject: Re: DLL's in console applications
From: [email-masked] (Colin Peters)

15 Dec 1997 20:45:25 -0800
Message-ID: <[email-masked]>
Reply-To: "Colin Peters" <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: 7bit
To: "Kees van Veen" <[email-masked]>
Cc: "GNU-Win32" <[email-masked]>

From: Kees van Veen <[email-masked]>
Date: Tuesday, December 16, 1997 2:25 AM

>But now it looks like every time an instance of the application starts,
>all the DLL's are loaded again as well. The DLL's together amount to
>about 10Mb, and this will increase in the future. My aim was to get them
>to work as a sort of shared libraries.

It is my understanding that this is natural. When any instance of an
application starts it should map all of it's DLLs into it's own memory
space. I believe that whether the DLLs are relocated or not can influence
their "memory" use (that is, whether they are backed by the DLL files or
by the swap file) but in either case each instance will be getting it's
own pages of real memory. I also cannot conceive of any way of sanely
doing static data for DLLs except giving each instance it's own copy of
the data pages (probably with "copy on write" set). Some expert please
correct me if I'm wrong.

They are shared libraries, in the sense that each instance uses the same
files to obtain the shared code to build the executable image in memory.
However, I don't believe you are going to reduce memory usage of multiple
instances of an application by using shared libraries under Win32. You
might want to investigate ways to run your application as a single
instance, or splitting up the functionality of the DLLs into smaller
chunks so that only the DLLs needed can be linked to the application.

>Now I heard my collegue mumble something about console applications
>running in a sort of protected environment, that's why all the DLLs are
>loaded again.

Your colleague was probably thinking about DOS applications, which each
run in a separate virtual machine. Win32 console applications run in the
same virtual machine as all other Win32 applications AFAIK.

>Would it help to link the DLLs as 'windows application'.

I don't think so, but you could try it and see.

Colin.

-- Colin Peters -- colin at fu.is.saga-u.ac.jp
-- Saga University Dept. of Information Science
-- http://www.fu.is.saga-u.ac.jp/~colin
-- http://www.geocities.com/Tokyo/Towers/6162

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".