What is DLL base address

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newish

    What is DLL base address

    Hi

    Regarding DLL base address:

    1) What does it mean?

    2) Should it ever be changed?

    3) What are the rules to change it?

    It defaults to &H00400000.

    Regards

    Newish

  • Jani Järvinen [MVP]

    #2
    Re: What is DLL base address

    Hello,
    Regarding DLL base address:
    1) What does it mean?
    A base address for a DLL is the virtual memory address into which it gets
    loaded by default.

    If I simplify things somewhat, all 32-bit Windows applications have a 2GB
    memory space. When your application starts, this virtual memory space is
    created by the operating system (OS), and it is virtual in a sense that
    multiple processes can inside their address space refer to memory locations
    with the same addresses, but the OS makes sure there are no actual
    collisions.

    Now, every EXE needs one or more DLLs, often the count can be something in
    the range of 30-50 DLLs, most of which are OS DLLs. Each of these DLLs has a
    base address, which, as I mentioned is the memory address into which it gets
    loaded by default. Since two DLLs cannot be loaded into the same address,
    the OS much "rebase" the DLL that is loaded if it has the same base address
    as another DLL. This is a relatively slow operation.

    Matt Pietrek has written an article about this to the May 2000 issue of MSDN
    Magazine:

    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    2) Should it ever be changed?
    Since "rebasing" is costly, the answer is in yes, it should be changed.
    However, it is arguable whether changing the base address actually has any
    (real world) effect in the performance of your application. Sure, the effect
    can be measured, but since you cannot know in advance which address would be
    "collision-free" (since you can't control the base addresses of all those OS
    DLLs), it is often a hit-and-miss thing.

    So if you are writing a basic .NET application with one of two DLLs
    (libraries), it probably doesn't make any difference to keep the default
    values versus to change it. But if you have a big application with dozens of
    libraries and performance is critical, consider changing the default values
    of all your DLLs to unique values.
    3) What are the rules to change it?
    See the documentation of the /baseaddress command-line option for the C#
    compiler:



    Hope this clarifies the situation.

    --
    Regards,

    Mr. Jani Järvinen
    C# MVP
    Helsinki, Finland
    janij@removethi s.dystopia.fi



    Comment

    • Cowboy \(Gregory A.  Beamer\)

      #3
      Re: What is DLL base address

      1) This is the memory address it will attempt to load in first.
      2) Not so much in .NET (this group), but there are definitely reasons to
      change in traditional VB, where having each DLL at a different address will
      reduce start up time of the app as it does not spend the time finding a good
      address to store the DLL in memory.
      3) If you are in VB 6, I would always change it. I do not have rules in
      front of me (offline at the time I am typing this), but it should be easy
      enough to find a base address project still and download (codeplanet.com is
      where I think I have seen one).

      --
      Gregory A. Beamer
      MVP; MCP: +I, SE, SD, DBA


      *************** *************** *************** ****
      Think Outside the Box!
      *************** *************** *************** ****
      "Newish" <ahussain3@gmai l.comwrote in message
      news:1160203755 .135721.254000@ m7g2000cwm.goog legroups.com...
      Hi
      >
      Regarding DLL base address:
      >
      1) What does it mean?
      >
      2) Should it ever be changed?
      >
      3) What are the rules to change it?
      >
      It defaults to &H00400000.
      >
      Regards
      >
      Newish
      >

      Comment

      • Greg Young

        #4
        Re: What is DLL base address

        jani:

        You are correct for unmanaged stuff but this is not the case with JIT
        compiled code.

        The situation will also arise if you are using ngen .. but again rebasing is
        not a major concern with JIT compiled code.

        Cheers,

        Greg
        "Jani Järvinen [MVP]" <janij@removeth is.dystopia.fiw rote in message
        news:eWGM45g6GH A.4620@TK2MSFTN GP02.phx.gbl...
        Hello,
        >
        >Regarding DLL base address:
        >1) What does it mean?
        >
        A base address for a DLL is the virtual memory address into which it gets
        loaded by default.
        >
        If I simplify things somewhat, all 32-bit Windows applications have a 2GB
        memory space. When your application starts, this virtual memory space is
        created by the operating system (OS), and it is virtual in a sense that
        multiple processes can inside their address space refer to memory
        locations with the same addresses, but the OS makes sure there are no
        actual collisions.
        >
        Now, every EXE needs one or more DLLs, often the count can be something in
        the range of 30-50 DLLs, most of which are OS DLLs. Each of these DLLs has
        a base address, which, as I mentioned is the memory address into which it
        gets loaded by default. Since two DLLs cannot be loaded into the same
        address, the OS much "rebase" the DLL that is loaded if it has the same
        base address as another DLL. This is a relatively slow operation.
        >
        Matt Pietrek has written an article about this to the May 2000 issue of
        MSDN Magazine:
        >
        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

        >
        >2) Should it ever be changed?
        >
        Since "rebasing" is costly, the answer is in yes, it should be changed.
        However, it is arguable whether changing the base address actually has any
        (real world) effect in the performance of your application. Sure, the
        effect can be measured, but since you cannot know in advance which address
        would be "collision-free" (since you can't control the base addresses of
        all those OS DLLs), it is often a hit-and-miss thing.
        >
        So if you are writing a basic .NET application with one of two DLLs
        (libraries), it probably doesn't make any difference to keep the default
        values versus to change it. But if you have a big application with dozens
        of libraries and performance is critical, consider changing the default
        values of all your DLLs to unique values.
        >
        >3) What are the rules to change it?
        >
        See the documentation of the /baseaddress command-line option for the C#
        compiler:
        >

        >
        Hope this clarifies the situation.
        >
        --
        Regards,
        >
        Mr. Jani Järvinen
        C# MVP
        Helsinki, Finland
        janij@removethi s.dystopia.fi

        >
        >

        Comment

        Working...