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

VulpesRank #55 · 29.2K reputationPosted Mar 3, 2011, 11:43 PM EST
patrickRank #4,458 · 342 reputationPosted Mar 4, 2011, 6:27 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 4, 2011, 6:46 AM EST
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).
patrickRank #4,458 · 342 reputationPosted Mar 4, 2011, 4:48 PM EST
Sam HobbsRank #107 · 20.5K reputationPosted Mar 4, 2011, 6:56 PM EST
patrickRank #4,458 · 342 reputationPosted Mar 5, 2011, 2:43 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 5, 2011, 4:02 AM EST
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/).
patrickRank #4,458 · 342 reputationPosted Mar 5, 2011, 6:17 AM EST
- 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.
Sam HobbsRank #107 · 20.5K reputationPosted Mar 5, 2011, 7:37 AM EST
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.
patrickRank #4,458 · 342 reputationPosted Mar 5, 2011, 10:10 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Mar 5, 2011, 10:55 AM EST