Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DLL size in memory & size on the hard disk

Is there a relationship between DLL size in memory and size on the hard disk?

This is because I am using Task Manager extension (MS), and I can go to an EXE in the list and right click -> Module, then I can see all the DLLs this EXE is using. It has a Length column, but is it in bytes? And the value (Length) of the DLL seems to be different from the (DLL) size on the hard disk. Why?

like image 234
RoundPi Avatar asked Mar 18 '12 20:03

RoundPi


1 Answers

There's a relationship, but it's not entirely direct or straightforward.

When your DLL is first used, it gets mapped to memory. That doesn't load it into memory, just allocates some address space in your process where it can/could be loaded when/if needed. Then, individual pages of the DLL get loaded into memory via demand paging -- i.e., when you refer to some of the address space that got allocated, the code (or data) that's mapped to that/those address(es) will be loaded if it's not already in memory.

Now, the address mapping does take up a little space (one 4K page for each megabyte of address space that gets mapped). Of course, when you load some data into memory, that uses up memory too.

Note, however, that most pages can/will be shared between processes too, so if your DLL was used by 5 different processes at once, it would be mapped 5 times (i.e., once to each process that used it) but there would still only be one physical copy in memory (at least normally).

Between those, it can be a little difficult to even pin down exactly what you mean by the memory consumption of a particular DLL.

like image 88
Jerry Coffin Avatar answered Oct 24 '22 13:10

Jerry Coffin