dnlib vs cecil memory usage camparing
See original GitHub issueI tried with PaintDotNet assemblies, What is your opinion?
dnlib usage memory 133MB
var moduleContext = new ModuleContext();
var asmResolver = new AssemblyResolver(moduleContext, true);
var resolver = new Resolver(asmResolver);
moduleContext.AssemblyResolver = asmResolver;
moduleContext.Resolver = resolver;
ModuleDefMD moduleDefMd = ModuleDefMD.Load(@"D:\PaintDotNet.exe", moduleContext);
moduleDefMd.Write(@"D:\PaintDotNet_Save.exe");
cecil usage memory 40MB
ReaderParameters readerParameters = new ReaderParameters
{
AssemblyResolver = new CustomResolver()
};
ModuleDefinition moduleDef = ModuleDefinition.ReadModule(@"D:\PaintDotNet.exe", readerParameters);
moduleDef.Write(@"D:\PaintDotNet_Save.exe");
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
What's the difference between AsmResolver and dnlib? #111
It allows for preserving metadata tokens, and allocating and assigning new metadata tokens to new members before saving a module to the disk....
Read more >RoyIL/dnlib
Cecil can't handle obfuscated assemblies, doesn't fully support mixed mode assemblies, doesn't read .NET assemblies the same way the CLR does and many...
Read more >Accessing Assembly Metadata with Reflection or Mono ...
it uses a lot more memory than Reflection – roughly twice as much on average (it varies from 50% more to twice as...
Read more >c# - How can I programatically (using reflection?) change a ...
I believe that changing the method body will be less error prone than trying to use Assembly/Module/TypeBuilder and Reflection.Emit to try and ......
Read more >Challenge 8: backdoor
The challenge uses the concept of Dynamic Methods in .NET to conceal meaningful code from static analysis and debugging tools like dnSpy.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like it’s the mmapped IO. With it disabled (use File.ReadAllBytes()) and reading PDB files is disabled, process explorer says WS is 69MB (dnlib) vs 52MB (cecil). WIth mmapped IO enabled, dnlib’s WS is 112MB. The example is similar to yours except I made it more real-world by iterating over all types and members and reading method bodies.
The most important part of dnlib is that it can read obfuscated assemblies. That’s the reason I wrote it. If it uses more memory and more CPU, then that’s OK with me because it must be able to read real world assemblies, not only assemblies following the ECMA spec. Memory is very cheap.
I attached example cecil and dnlib,
Example.zip Please download Paint.Net https://www.dotpdn.com/files/paint.net.4.0.21.install.zip