Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

General "Component Already Exists" Question

Posted on 2006-04-04
4
Medium Priority
?
4,882 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:alexiat
  • 2
4 Comments
 
LVL 11

Expert Comment

by:pcsentinel
ID: 16370068
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
 

Author Comment

by:alexiat
ID: 16370187
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 16370333
>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
 
LVL 11

Accepted Solution

by:
pcsentinel earned 2000 total points
ID: 16370346
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question