Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings :)
In my C# application, I copy a binary file, in chunks, parse it for data, and then reassemble / copy the binary file to a separate loacation. The process is pretty fast, so the CPU and memory peaks during the process, then settles out upon completion.

My question is : can I limit the amount of (1.)memory peak and/or (2.)CPU peak ?

I'm wondering that if I put in a simple delay, taking longer to process, would that use less CPU AND memory, even though the process would take longer to complete ?

Thanks ahead ;)
Posted
Comments
[no name] 13-Jul-13 9:39am    
Sure you could. Why would you want to and what difference would it make?

1 solution

As ThePhantomUpvoter asked: why? The windows resource management engine is pretty good, also in combination with the managed runtime. As you can probably not know about all environment where your application will run, you should not try to predict the resources available in that system. Let the system manage it. But you can specify the priority[^] of your process, however this has no direct effect on the memory usage, that is under your control in all situations: you are the one who allocate buffer space and you decide how many data you wish to process at once. The virtual memory architecture is letting you use much more than the physically available memory. However you can use the actual memory information[^] to allocate memory for your process depending on the available physical memory. Thus you might have the chance not to be paged - especially on an x64 system. You could also find some low level API functions that you could use to allocate unmanaged memory, or force physical memory allocation. Still, I don't think you would really need such thing.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900