Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?

This question is asked in our internal discussion list. One of the kernel developer answered the question below:

<quote>

LoadLibrary(AlreadyLoadedModule) has to increment the reference count of AlreadyLoadedModule, plus all of that module's dependencies, and their dependencies, recursively. Since the dependencies are recorded by name, not by a pointer to the loader entry, finding each dependency requires applying the isolation/redirection info in the activation context. For a module with a lot of imports, or imports which have their own large trees, this makes a LoadLibrary call quite expensive, even if it's already loaded.

GetModuleHandle is a better alternative.

<quote>

This is a FYI post. I won't answer any question.