My program is hitting 500,000k memory and more until it crashes. It uses 50,000k when it first loads. I realized that it climbs in usage and never goes down, and I think I have narrowed the problem down to the way I am switching forms. Here is my code:
if (Properties.Settings.Default.isCashRegister)
{
callerIDTimer.Enabled = false;
if (Functions.IsConnectionAvailable())
{
if (Settings.Default.NumberOfRegisters != 1)
{
var cashRegisterInstance = new cashRegisterForm(Properties.Settings.Default.registerNumber);
}
else
{
var cashRegisterInstance = new cashRegisterForm(1);
Hide();
cashRegisterInstance.Show();
cashRegisterInstance.FormClosed += Instance_FormClosed;
}
}
else
{
MessageBox.Show(Classes.ErrorMessages.ConnectionError1.ToString());
}
}
else
{
MessageBox.Show("Not a cash register station.");
}
Does anyone know where the problem might be?
Loading
VulpesPosted Mar 4, 2011, 4:43 AM
Sam HobbsPosted Mar 5, 2011, 3:55 PM
patrickPosted Mar 5, 2011, 3:10 PM
Sam HobbsPosted Mar 5, 2011, 12:37 PM
When it stops responding, does it use processor time?
When you debug the program using a debug build, when it stops responding, try breaking into the program to see what it is doing.
patrickPosted Mar 5, 2011, 11:17 AM
- Onewire.net API which allows employee identification through i-button adapters - this isnt running on any open forms during the problem
- MySQL; every connection is created in a using{} block
- Microsoft Mappoint - the source of many headaches, this runs constantly in the background and the memory climbs without it doing anything.
- GlacialListBox - I dont know who the author of this was, I needed a list box that could list multiple rows of items in a single cell. This could very well be the culprit, as it opens on several of the offending forms.
VulpesPosted Mar 5, 2011, 9:02 AM
For example COM interop with MS office applications or P/Invoking some unmanaged functions which require you to allocate a block of unmanaged memory first (using Marshal.AllocHGlobal or the COM memory manager). A common error in the latter case is forgetting to call Marshal.FreeHGlobal when you've finished using the memory which will cause a leak.
If ANTS is no help, then you could try JetBrains instead (http://www.jetbrains.com/profiler/).
patrickPosted Mar 5, 2011, 7:43 AM
Sam HobbsPosted Mar 4, 2011, 11:56 PM
patrickPosted Mar 4, 2011, 9:48 PM
VulpesPosted Mar 4, 2011, 11:46 AM
There's a 14 free trial of the ANTS profiler (http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/?utm_source=google&utm_medium=cpc&utm_content=unmet_need&utm_campaign=antsmemoryprofiler&gclid=CJf_tPOttacCFUtC4QodwGmS-w).
patrickPosted Mar 4, 2011, 11:27 AM