Search code examples
c#cpu-usagedotnetzip

How can I optimize or limit the CPU usage a zip process (DotNetZip) in c#?


Good day guys

I have an app that I use to archive a folder using the DotNetZip library. I notice that when it goes to the actual "zipping" process, it uses up 100% of the CPU. This app will be used in conjunction with another (a tcp chat application) so I really need this to use as less cpu as possible.

Is there any way I can safely limit the cpu? I've tried lowering the priority but it doesn't make a difference. The only thing I have right now is setting the affinity to 1 core only so that it uses 50%. But of course that would only work on multi-core computers.


Solution

  • Lowering the priority is what you want, not necessarily forcing the process to only use an arbitrary amount of the CPU like 50%.

    This means that the process will use as much unused processing capacity of the CPU, and that your other more important processes will still be able to function almost as if the Zip process wasn't running at all.

    I should think that the low priority process is only using 100% of the CPU because nothing else is. Once you get your other process(es) up and running and try it again, you will notice that the Zip process will not use 100%.