Solved

Delphi 7 debugger hangs briefly on application exit

Posted on 2007-12-05
7
1,205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:2266180
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:
2266180 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
Technology Partners: 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!

 
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:2266180
2266180 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:2266180
ID: 20416153
now there is a weird thing to keep in mind :)
0

Featured Post

Technology Partners: 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

635 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