Author Topic: Tip - Memory optimization for executables  (Read 1863 times)

0 Members and 1 Guest are viewing this topic.

exmachina

  • Guest
Tip - Memory optimization for executables
« on: October 18, 2011, 10:45:53 PM »
Like SmartAssembly(www.red-gate.com)-> Other optimizations->You can reduuce the memory allocated... but open source

The (win API) SetProcessWorkingSetSize function sets the minimum and maximum working set sizes for a specified process. 

FROM MSDN:
The working set of a process is the set of memory pages currently visible to the process in
physical RAM memory. These pages are resident and available for an application to use
without triggering a page fault. The size of the working set of a process is specified in bytes.
The minimum and maximum working set sizes affect the virtual memory paging behavior of
a process.

The idea is simple, we just add an event handler to find out when the OnIdle event of the
application is raised, and when this happens we call the flush Procedure which reduces the
amount of ram consumed by the calling process, this event should be raised at most once every
10 seconds.
 
All you have to do is to create an instance of Mem class in your main form. Look at Mem.cs and MainForm.cs(constructor).