Solved

Delphi 7 debugger hangs briefly on application exit

Posted on 2007-12-05
7
1,176 Views
Last Modified: 2013-11-23
Experts,

I use Delphi 7. On occasion, when I am running an application in the debugger and I exit the application normally, Delphi seems to get hung, and hangs the rest of my computer desktop as well. This always remedies itself after some period of time. Sometimes it takes a few seconds, sometimes as much as a minute, and sometimes not at all  all within the same application. It only happens when debugging, the applications all run fine outside of the debugger. This only happens when I terminate the application normally  if I do a Program Reset I return to the debugger with no delay.

I have never been able to tell what is going on when this happens. Ive tried watching task manger when it occurs but even the task manager is not updating its screen when this goes on. I suspect its bad behavior on the part of some component that I am using because it does not happen with simple programs, only my more involved projects.

Has anyone else experienced this? Any Ideas?
 
Thanks,

Steve
0
Comment
Question by:SteveBay
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 20414630
are you using memcheck/fastmm with some debugging configured/etc? these kind of componetns will usually compute some information related to memory usage, but you should get some a message saying so because usually there is always something that is "left unreleased".

other then that, I am afraid you will have to provide us with the list of 3rd party components you are using in your project.
0
 
LVL 14

Author Comment

by:SteveBay
ID: 20415181
I use AQTime for profiling and memory leak detection. It is not integrated with the debug environment.

The 3rd party component list is long and varied. So I looked for the lightest application I could find that has exhibited this behavior.

This particular application is a DLL that reads data from an XML and updates Data in a MSSQL database. Its 3rd party components are limited to the following:

Raize Components (Ive use them in just about every thing for many years. I highly doubt that these are the problem).

There are also a number of CodeSite calls (also from Raize).
This could be a suspect because it sends windows messages and could be sending millions upon exit. I have made efforts to disable all CodeSite calls and have still seen the behavior. This also would not explain why it only happens in the debugger as CodeSite works the same with or without the debugger. And once again, I've been using it for many years in lots of stuff and this issue has only come up recently, the last 6-8 months or so. I've also search Raize news groups for similar reports and found none. Still, I am not ready to completely rule this one out.

TLbBlowFish  - formerly from TurboPower now open source from Source Forge;

NativeXML - from www.simdesign.nl/xml.html. Theres not enough going on in this component to warrant unexpected behavior.


0
 
LVL 28

Accepted Solution

by:
ciuly earned 500 total points
ID: 20415382
>> It is not integrated with the debug environment.
it doesn't have to be. these components usually detect if the debugger is running or not.

in any case, first place to look at, are the finalization sections of the units.

if nothing comes up after a quick view, I would do somethign like the following to detect where the "freeze" occures:
- use a logging system
- log a line right after application.run in the dpr file
- log a line in the destructor of the main form as well
- create 2 units, named blabla1 and blabla2 (name it to whatever you like), and in the finalization section add a log line in both
- logging usefull information is a must (like: now executing finalization section of unit blabla1, or destructor of main form, etc)
- the logger must be able to also log the time of the call so that you know when the message was logged

now, with this prepared (it should really only take a few minutes to setup everything, provided you have a logging system with the minimum characteristics mentioned above).

now, step 2:
- place the unit blabla1 as the first unit in the dpr, BUT, without messing up whatever other units MUST be first (like madexcept, fastmm, etc. probably your AQTime also has a unit there first). this blabla1 will come the first after all the others
- place the unit blabla2, as the last unit in the dpr.

and now, I think you know what comes :) trial and "error" of the "divide et impera".
looking in the logs, you will notice where the "freeze" is happening. if you're lucky, you find it fast from the first call as belonging to either the first units from the dpr, or to some code after the main form destruction and project finalization.
if not, then you will notice the freeze to be between blabla1 and blabla2. so, move blabla1 down some units (preferably half). is it still between blabal1 and blabla2? if yes, again move it down, if not, move it back to first and move blabla2 in it's place. repeat.
eventually, you will end up with who is making the freeze.

it's ugly, but I don't know of any automated tool to trace the execution time of calls.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Author Comment

by:SteveBay
ID: 20415651
Good stuff ciuly...:)

CodeSite is my logging util. I put a call in the dpr right after the Run. and I put one in the Mainform destructor. Both of those were called before the hang occured.

BTW I ran the program 5 times and it only causes a hang once about 30 seconds.

I don't know what you are refering to by "finalization section of unit". Is that the form destructor?
0
 
LVL 28

Assisted Solution

by:ciuly
ciuly earned 500 total points
ID: 20415918
no. in a unit you have a several sections:

interface
implementation
initialization
finalization

the most used are the first 2. but there are cases when the otehr 2 are used as well. so some of you runits will have them some not.

see below example of blabal1.pas
unit blabla1;
 

interface
 

implementation
 

initialization

// nothing
 

finalization

  log('blabla1');
 

end.

Open in new window

0
 
LVL 14

Author Comment

by:SteveBay
ID: 20416040
Thanks,
You know, sometimes all a guy has to do is hit F1 and type a word (in this case "finalization") and a whole world of knowledge come pouring out:)

So I've done all of that and I will watch for the results.

In the mean time, just for grins, I when into Project->Options->Compiler and disabled everything in the Debugging section. The hang went away. (keep in mind it was only happing about 1 in 5 runs to begin with). I re-enabled every thing in the Debugging section, and the hang stayed away. I have not been able to reproduce the hang at all now. after several dozen runs - no hang.
Hmmm.

Your help has been quite valuable.  Thank You

0
 
LVL 28

Expert Comment

by:ciuly
ID: 20416153
now there is a weird thing to keep in mind :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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 video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

18 Experts available now in Live!

Get 1:1 Help Now