General "Component Already Exists" Question

Posted on 2006-04-04
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:

  Execute   //where "Execute := ShowModal=mrOk"

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.
Question by:alexiat
    LVL 11

    Expert Comment

    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;


    Author Comment

    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?
    LVL 27

    Expert Comment

    >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 ;-)
    LVL 11

    Accepted Solution

    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.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now