Re: Performance worrying problem - Bad architecture maybe

Tech-Archive recommends: Fix windows errors by optimizing your registry



Forms shown with ShowDialog are intentionally not disposed when closed, as
the runtime assumes it will be used again. If you're doing something like
this, you're going to have a problem:

OnButtonClick(...)
{
MyForm frm = new MyForm();
frm.ShowDialog();
}

This will create a new form instance every time the routine runs, and since
they're never explicitly destroyed, you could have garbage all over the
place. Especially if you're running an early CF 1.0 release, which had a
bug that didn't dispose all Form internals.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Lonifasiko" <mloichate@xxxxxxxxx> wrote in message
news:1134663130.680265.22910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi guys,
>
> I've got a very worrying problem in my CF 2.0 application. I don't know
> the exact reason for so poor performance, sometimes combined with
> "OutOfMemoryException" messages. Could be a bad architecture design
> problem.
>
> Ths is my actual scenario:
>
> The application has got near 25 forms and I have one MasterForm from
> which the rest of the forms inherit. This MasterForm contains basically
> icons and some static variables I use for different purposes inside all
> forms of my application.
>
> I call the first form of my application "MainForm". Here we have three
> very different choices (imagine three buttons).
> When any button is clicked, I always open corresponding form with
> ShowDialog() method. Each choice can simultaneously open 5/6 forms
> maximum by using ShowDialog(). Therefore, I understand 5/6 forms are
> opened in memory sametime. Correct me if I'm wrong please.
>
> Imagine that I choose a button and navigate and navigate and.....I
> finally have 5/6 forms opened with ShowDialog(). When I close the
> actual modal form (fifth or sixth form), I use the simple this.Close()
> and sometimes also return a DialogResult value. If the previous form
> must perform an specific action, I use static variables of the previous
> form, which I activate from the actual modal form.
>
> In the previous form, I capture Activate event and do the correct
> action if the corresponding static variable has been activated. An
> example would be to save something and when returning to the previous
> form, refreshing the screen with the newly saved data. This means a new
> database access. This could be the main bottleneck of the application.
>
> The operations are against SQL Mobile 2005 database. I always access
> database to retrieve
> latest data, don't use caching at all.
>
> With this scenario, all I can tell you is that sometimes application
> seems not to response, and ultimately, if you stress it hard,
> "OutOfMemoryException" occurs and new data is not refreshed in the
> screen. Suddenly data is "lost", and if you close the from and open it
> again, data appears again......in one word: desperating!
>
> I would like to hear any suggestion for a better performance please. It
> really hurries me. My project is becoming more and more complex and I
> think now, I've got the last chance to reorient or redesign its
> architecture. 2006 could be too late.
>
> Specially advices related to the way of opening/closing forms and
> database accessing and caching.
>
> Thanks very much. Regards.
>


.


Quantcast