Re: Resource file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ralph (nt_consulting64_at_address.com)
Date: 09/07/04


Date: Mon, 6 Sep 2004 21:26:05 -0500


"J French" <erewhon@nowhere.com> wrote in message
news:413c6b35.106916318@news.btclick.com...
> On Mon, 6 Sep 2004 07:58:33 -0500, "Norm Cook"
> <normcookNOSPAM@cableone.net> wrote:
>
> >When you you use a resource file, it is compiled into your exe.
Therefore, when
> >you run your compiled exe, the exe, along with the resources, get loaded
into
> >memory. Thus accessing your resources is memory access which is the
fastest
> >and most efficient access--as opposed to registry, ini file, database, or
file access.
> >
>
> <snip>
>
> Are you absolutely sure that resources are loaded into memory ?
> ie: mapped in with the EXE code and data
>
> That strikes me as rather daft, as the whole point of using them is
> supposed to be to /save/ memory.
>
>

When it comes to defining "loaded into memory" it can get rather
complicated, as what we are really talking about is "memory-mapping" into
Virtual Memory Management. The Win32 "program loader" memory-maps the PE
file format into virtual memory, for example. However, the entire program
and all its code and data is seldom actually in "memory" at any one moment.

Different resources datatypes are even "loaded" (memory-mapped) by slightly
different means. Bitmaps generally show up as single "blocks". Dialog
resources are used to "Read in" instructions on how to build something - the
resource itself doesn't 'stick around'. StringTables are managed thru a
manager that first loads the IDs which are 'mapped' to the various strings,
which may only be actually "in-memory" in 4k(8k) chunks. An API request for
a string ID, "loads" that particular chunk. The chunks may stick around or
be paged out frequently depending on the over-all load on the machine - as
the whole process is still dependent on the Platform's Virtual Memory
management.

Basically all Norm was pointing out was that loading strings from a resource
is generally faster than using File I/O - which is the same as saying
memory-mapped files are 'fetched' quicker than going to the disk. This is
one of the advantages of using a resource data file.

There is, however, always a trade-off. Loading an extremely large
stringtable and randomingly fetching values from it can sometimes be slower
than loading a single file and parsing it like an array. Like everything
else in computing - whenever you get to the 'outer limits', or the edges of
the envelope, of any technology, you need to test and see what the results
are in YOUR problem domain.

-ralph



Relevant Pages

  • Re: REGION=0M and LSQA
    ... At the time, memory was very expensive, and we ... remaining storage and always issued a return code zero. ... programs actually worked in production, ... all of the resources used by the job up until that point ...
    (bit.listserv.ibm-main)
  • Re: Resource file
    ... the memory ... >>When you you use a resource file, it is compiled into your exe. ... Thus accessing your resources is memory access which is the fastest ...
    (microsoft.public.vb.general.discussion)
  • Re: A realistic price comparison
    ... > Spreading Apple FUD is just as bad as spreading Microsoft FUD. ... > However, I assure you, I had more than enough resources on my XP ... > instilled in them by having limited memory and disk space early on. ...
    (comp.sys.mac.advocacy)
  • Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3?
    ... pretty much have memory bugs, ... having to do manual cleanups for 100% of your resources or for only 1%? ... This is a slight problem in languages like Java that have GC but no flow-control abstraction. ... Languages like Lisp and Smalltalk are another story: it's easy to have a with-open flow control construct that runs some subordinate code and then cleans up, and to have this be the standard way to use such things. ...
    (comp.programming)
  • Re: Fork bombing a Linux machine as a non-root user
    ... It is past time for the linux enthusiats touting linux as more ... systems limited resources (CPU time, physical memory, and so on). ...
    (Fedora)