question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Saved modules grow in size

See original GitHub issue

I compile an assembly using Visual Studio 2010, C#. Target Framework is version 4 Client Profile. Output type is class library. Platform target is Any CPU. Optimize code is on. Allow Unsafe code is off. There are no managed resources and no native resources. The assembly is signed (strong name).

The PE Header says: Section Alignment = 8192 File Alignment = 512

.text section is 254 KB .rsrc section is 1 KB .reloc section is 512 bytes

CLR Header says MetaData is 147,59 KB

Total file size is 256 KB.

I then open the module using

ModuleDefinition md = ModuleDefinition.ReadModule(modulepath);

and save it using

WriterParameters wp = new WriterParameters
{
    WriteSymbols = md.HasSymbols
};

md.Write(modulepath, wp);

The new file is now 258.5 KB.

The .text section has grown to 255.5 KB A .sdata section has been added, 512 bytes

CLR Header says MetaData is now down to 147.5 KB.

The .text section should not grow. A .sdata section should not be added. The total file size should not increase (It would be ok if it went down without loosing information).

I have not tested this on other modules.

Issue Analytics

  • State:open
  • Created 13 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
KrisVandermottencommented, May 12, 2010

I don’t think it’s fear, rather prudence, being careful. I’ve tracked down many bugs in my time based on a smell.

Also, unit tests are very valuable, but they’re just that: unit tests. In addition to unit tests, I always run a battery of static analysis tools on my code. Often I also perform stress tests and other kinds of tests.

In this specific case, I run evertything that comes out of Cecil (after being modified by my code) through its battery of tests and validations, but also through peverify and other low level pe file analysers. I will also look at JIT compiler output, to verify that my modifications do not disable JIT optimizations.

Like you say, there can be an obscure bug everywhere, but the more eyes (tests and validaion tools) look at the code (in different ways), the smaller the chances are.

0reactions
SimonCroppcommented, Sep 6, 2014

@jbevain think this one can be closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node module size: See how I reduced it by 90%
It'll print every module that has a size of at least 1MB. By doing this you will know which modules take up the...
Read more >
Saved State module for ViewModel
When using this module, ViewModel objects receive a SavedStateHandle object through its constructor. This object is a key-value map that ...
Read more >
Common modularization patterns
Every module introduces configuration overhead. If the number of your modules reaches a certain threshold, managing consistent configuration becomes a challenge ...
Read more >
Lazy Modules and bundle size - angular
I'm trying to unpack why some of my modules are so big when in essence they are referencing the same modules/libraries across each...
Read more >
Multisowing modules to save time, compost and greenhouse ...
I fill a module tray then sow peas, radish, beetroot and onions/spring onions. After 3-5 weeks, I plant these as clumps.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found