We are developing Automation Software for Restaurants(using VS.NET C#). And we are using POS products which mostf of them has celeron or atom processor with 512 mb or 1gb ram on it. So at the begining know that we can't get more powerfull PC(i saw suggestion like "Get a better PC to your customer" :) ).
We have a memory problem. To represent the cart of a real customer, we use panel, we add custom control to represent product in cart. These means lots of controls are adding to panel, then removing(Panel.controls.Clear function.) This method causes a memory leak and program goes slow performance. After searching and googling, i found that Panel.Control.Clear() funtction clears all the control in the panel but not from the memory. So i disabled the panel to check, and wholaaa everything workss fine. No memory leaks anymore. So i decided to remove that cart panel to save memor. But later i found very usefull suggestions here, like EmptyWorkingSet.
[DllImport("psapi.dll")]
static extern int EmptyWorkingSet(IntPtr hwProc);
static void MinimizeFootprint()
{
EmptyWorkingSet(Process.GetCurrentProcess().Handle);
}
Then i added the code , enabled the cart panel, and it nothing changed. Performance is still good.No memory leak, no performance decreased. But some says in here and here EmptyWorkingSet may causes Page Faults and it is dangerous. I'am testing program and nothing happened. It works like a charm. So these are my options
- Remove the cart panel that causes memory problems.
- After clearing custom controls from cartPanel , remove the custom controls from the memory( i don't know how but i can figure it out)
- USE EmptyWorkingSet but it may cause page faults(truely i don't know what is that Page Fault mean)
SO WHAT DO YOU SAY