General "Component Already Exists" Question

We have a customer who is using an app written in Delphi5.  Although I don't know exact numbers,
it is a very large app that is RAM intensive.  We have thousands of users with this app and none
have had this problem but this one user.  She says she is using XP with 1000 KB RAM.

The user says she is getting an error message of "A component named MyEditDlg already exists" from
the app.  It can happen after the first "edit" or go for days with no problems at all.  This
component is called from several places, but she is only calling it from one specific location.
The component is called via:

Create
try
  Execute   //where "Execute := ShowModal=mrOk"
finally
  Free

The user claims that if she closes the app and restarts it the error message still occurs.  She
also claims that if she reboots the computer it may or may not still occur.

I am hoping with your expertise you can give me some direction on how this can be happening.

I understand from research the error message is from the component not being released before it
is called again.  I just don't see how this can be from the above code, nor can I understand how
rebooting wouldn't get rid of the problem.  Is there a difference between completely shutting
down the computer and doing a restart versus a reboot.  Is there any way this error could occur from
insufficient memory on her computer?

I realize this is quite a general question but I am hoping someone can give me some insight on
this problem (so I can get some sleep!)

As always, Thanks.
alexiatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcsentinelCommented:
I have noticed that there can be occasional problems like this where for some reason a created and called form does not get freed properly and it was in Delphi 5. Whats more the problem only occurred if you did something in a particular order.

I never found a complete answer to the question, I ended up ensuring that minimal number of forms were created at start up and to use FreeAndNil not Free e.g.

procedure TfrmMain.ShowAbout;
begin
  Application.CreateForm(TfrmAbout,frmAbout);
  try
    frmAbout.ShowModal;
  finally
    FreeAndNil(frmAbout);
  end;
end;


regards
0
alexiatAuthor Commented:
I guess that makes me feel a little better.  :-)

I didn't know about FreeAndNIL.  The fact that the problem could be particular to Delphi5 and events occuring in a particular order makes sense.  Can you explain how (or if it is, in fact, possible), for a reboot not to fix it?
0
kretzschmarCommented:
>A component named MyEditDlg already exists
usual this error comes up, if you want to name a object with the same name of an already existing object

so it seems your dialog is not destroyed and resists already in the applications component-list

if FreeAndNIL can resolve this, don't know, because this dialog may used in other parts too,
or may autocreated  caused by the project-options

meikl ;-)
0
pcsentinelCommented:
In a word No, I dont think its anything to do with a reboot but how the user is using the application. It may even be related to how many other programs are running and consuming resources. Check that the form is not being created at startup, one time I did make the mistake of leaving it as autocreate but and then trying to create it on the fly. Also check that there is no way the code allows for the form not to be freed, i.e. if the user clicks on the close X rather than a dialog button what happens, does the dialog allow any other flow path apart from returning to the calling form.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.