none
Reduce memory consumption RRS feed

  • Question

  • Hi,
    I'm trying to reduce the memory consumption of a large scale system.
    The system is based on thousands of DLLs.
    I'm trying to understand what actions can I take regarding the large amount of DLLs in order to reduce the memory consumption.

    One thought I had in mind is merging DLLs in order to minimize the meta-data stored in memory.
    What do you think? any other ideas?

    Thanks.

    Lior
    Monday, March 15, 2010 6:38 AM

Answers

  • I would start with measuring, what takes that much memory. How much memory is from mapped files? (That's what you can help with merging assemblies) How much memory is allocated by native components? (Native heap) How much memory is allocated by GC? (GC heap) ... You can get many such information using tools like VMMap or various perf counters.
    Get those numbers first to see if merging assemblies will significantly help in your situation. It might, but it might not.

    Note that merging assemblies can help you only with Virtual Memory address space size (i.e. your system is 32-bit and uses more than 2/3GB of virtual memory, because it maps too many files). It cannot help you with amount of physical memory used by your system. For that you have to optimize usage of your native and GC heaps.
    If you have troubles with virtual memory address space, then you can also consider migrating your system to 64-bit. That will solve VM address space problem for you.

    About merging assemblies:
    If hundreds, or thousand of your assemblies are small (in tens of KB) and they heavily reference each other, then merging could help. If they are larger (100 KB+) or they don't heavily reference each other, then you will probably not gain that much. You can easily try this out on couple of sample assemblies using ildasm, merging the sources manually and ilasm the merged source files into a new merged assembly. Then you can compare sizes (I did this approach just last week with a set of 26 assemblies for an investigation).

    -Karel

    Monday, March 15, 2010 7:37 AM
    Moderator

All replies

  • I would start with measuring, what takes that much memory. How much memory is from mapped files? (That's what you can help with merging assemblies) How much memory is allocated by native components? (Native heap) How much memory is allocated by GC? (GC heap) ... You can get many such information using tools like VMMap or various perf counters.
    Get those numbers first to see if merging assemblies will significantly help in your situation. It might, but it might not.

    Note that merging assemblies can help you only with Virtual Memory address space size (i.e. your system is 32-bit and uses more than 2/3GB of virtual memory, because it maps too many files). It cannot help you with amount of physical memory used by your system. For that you have to optimize usage of your native and GC heaps.
    If you have troubles with virtual memory address space, then you can also consider migrating your system to 64-bit. That will solve VM address space problem for you.

    About merging assemblies:
    If hundreds, or thousand of your assemblies are small (in tens of KB) and they heavily reference each other, then merging could help. If they are larger (100 KB+) or they don't heavily reference each other, then you will probably not gain that much. You can easily try this out on couple of sample assemblies using ildasm, merging the sources manually and ilasm the merged source files into a new merged assembly. Then you can compare sizes (I did this approach just last week with a set of 26 assemblies for an investigation).

    -Karel

    Monday, March 15, 2010 7:37 AM
    Moderator
  • Hi Karel,
    Thanks a lot.
    That was very helpful, exactly what I was looking for.

    Lior
    Monday, March 15, 2010 11:19 AM